Refine search
/** * Draws the empty board, no pieces on it yet, just grid lines */ void drawEmptyBoard(Graphics g) { int x=x_offset, y=y_offset; Color old_col=g.getColor(); g.setFont(def_font2); old_col=g.getColor(); g.setColor(checksum_col); g.drawString(("Checksum: " + checksum), x_offset + field_size, y_offset - 20); g.setFont(def_font); g.setColor(old_col); for(int i=0; i < num_fields; i++) { for(int j=0; j < num_fields; j++) { // draws 1 row g.drawRect(x, y, field_size, field_size); x+=field_size; } g.drawString((String.valueOf((num_fields - i - 1))), x + 20, y + field_size / 2); y+=field_size; x=x_offset; } for(int i=0; i < num_fields; i++) { g.drawString((String.valueOf(i)), x_offset + i * field_size + field_size / 2, y + 30); } }
public void drawTopology(Graphics g) { int x=20, y=50; String label; Dimension box=getSize(); Color old=g.getColor(); if(coordinator) { g.setColor(Color.cyan); g.fillRect(11, 31, box.width - 21, box.height - 61); g.setColor(old); } g.drawRect(10, 30, box.width - 20, box.height - 60); g.setFont(myFont); for(int i=0; i < members.size(); i++) { label=members.get(i).toString(); drawNode(g, x, y, label, NormalStyle); y+=50; } }
/** * Draws a single-line highlight border rectangle. * * @param g The graphics context to use for drawing. * @param x The left edge of the border. * @param y The top edge of the border. * @param width The width of the border. * @param height The height of the border. * @param raised <code>true</code> if the border is to be drawn raised, * <code>false</code> if lowered. * @param shadow The shadow color for the border. * @param highlight The highlight color for the border. * @see javax.swing.border.EtchedBorder * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect */ public static void drawHighlightBorder(Graphics g, int x, int y, int width, int height, boolean raised, Color shadow, Color highlight) { final Color oldColor = g.getColor(); g.translate(x, y); g.setColor(raised ? highlight : shadow); g.drawLine(0, 0, width - 2, 0); g.drawLine(0, 1, 0, height - 2); g.setColor(raised ? shadow : highlight); g.drawLine(width - 1, 0, width - 1, height - 1); g.drawLine(0, height - 1, width - 2, height - 1); g.translate(-x, -y); g.setColor(oldColor); }
public void drawNode(Graphics g, int x, int y, String label, int style) { Color old=g.getColor(); int width, height; width=fm.stringWidth(label) + 10; height=fm.getHeight() + 5; g.setColor(node_color); g.fillRect(x, y, width, height); g.setColor(old); g.drawString(label, x + 5, y + 15); g.drawRoundRect(x - 1, y - 1, width + 1, height + 1, 10, 10); if(style == CheckStyle) { g.drawRoundRect(x - 2, y - 2, width + 2, height + 2, 10, 10); g.drawRoundRect(x - 3, y - 3, width + 3, height + 3, 10, 10); } }
public void paint(Graphics g) { if (isVisible()) { try { JTextComponent component = getComponent(); Rectangle r = component.getUI().modelToView(component, getDot()); Color c = g.getColor(); g.setColor(component.getBackground()); g.setXORMode(component.getCaretColor()); r.setBounds(r.x, r.y, g.getFontMetrics().charWidth('w'), g.getFontMetrics().getHeight()); g.fillRect(r.x, r.y, r.width, r.height); g.setPaintMode(); g.setColor(c); } catch (BadLocationException e) { e.printStackTrace(); } } }
/** * Paints the background. * * @param g The graphics context. * @param bounds The bounds of the object whose backgrouns we're * painting. */ @Override public void paint(Graphics g, Rectangle bounds) { Color temp = g.getColor(); g.setColor(color); g.fillRect(bounds.x,bounds.y, bounds.width,bounds.height); g.setColor(temp); }
/** A label field with custom font and color attributes */ private class CustomLabelField extends LabelField { private int fontColor = Color.BLACK; public CustomLabelField(String text, Font f, int color, long style) { super(text, style); setFont(f); fontColor = color; } public void paint(Graphics g) { int oldColor = g.getColor(); g.setColor(fontColor); super.paint(g); // reset graphics context g.setColor(oldColor); } }
/** * If the list is opaque, paint its background. * Subclasses may want to override this method rather than paint(). * * @see #paint */ protected void paintBackground(Graphics g) { if (isOpaque()) { Color backup = g.getColor(); g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(backup); } }
protected void paintSunkenBorder(Graphics g, Rectangle b) { Color old = g.getColor(); g.setColor(_shadowColor); // inner 3D border g.drawLine(b.x, b.y, b.x + b.width - 1, b.y); g.drawLine(b.x, b.y, b.x, b.y + b.height - 1); g.setColor(_lightHighlightColor); // black drop shadow __| g.drawLine(b.x, b.y + b.height - 1, b.x + b.width - 1, b.y + b.height - 1); g.drawLine(b.x + b.width - 1, b.y, b.x + b.width - 1, b.y + b.height - 1); g.setColor(old); }
private void paintRaisedBorder(Graphics g, Rectangle b) { Color old = g.getColor(); g.setColor(_lightHighlightColor); // inner 3D border g.drawLine(b.x, b.y, b.x + b.width - 1, b.y); g.drawLine(b.x, b.y, b.x, b.y + b.height - 1); g.setColor(_shadowColor); // black drop shadow __| g.drawLine(b.x, b.y + b.height - 1, b.x + b.width - 1, b.y + b.height - 1); g.drawLine(b.x + b.width - 1, b.y, b.x + b.width - 1, b.y + b.height - 1); g.setColor(old); }