@Override protected void paintComponent(Graphics g) { g.drawLine(0, 0, getWidth(), getHeight()); g.drawLine(10, 30, 50, 30); g.drawLine(10, 30, 10, 70); g.drawRect(50, 50, 120, 70); g.drawOval(50, 50, 120, 70); g.setColor(Color.RED); g.drawLine(0, getHeight(), getWidth(), 0); g.fillRect(80, 80, 100, 100); g.setColor(Color.GREEN); g.fillOval(80, 80, 100, 100); g.setColor(Color.BLUE); int[] xPoints = {100, 150, 50}; int[] yPoints = {10, 70, 70}; // g.drawPolygon(xPoints, yPoints, 3); g.fillPolygon(xPoints, yPoints, 3); }
/** Overrides <code>Graphics.drawLine</code>. */ public void drawLine(int x1, int y1, int x2, int y2) { DebugGraphicsInfo info = info(); if (debugLog()) { info() .log( toShortString() + " Drawing line: from " + pointToString(x1, y1) + " to " + pointToString(x2, y2)); } if (isDrawingBuffer()) { if (debugBuffered()) { Graphics debugGraphics = debugGraphics(); debugGraphics.drawLine(x1, y1, x2, y2); debugGraphics.dispose(); } } else if (debugFlash()) { Color oldColor = getColor(); int i, count = (info.flashCount * 2) - 1; for (i = 0; i < count; i++) { graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor); graphics.drawLine(x1, y1, x2, y2); Toolkit.getDefaultToolkit().sync(); sleep(info.flashTime); } graphics.setColor(oldColor); } graphics.drawLine(x1, y1, x2, y2); }
private void drawWinBorder(Component c, Graphics g, int x, int y, int w, int h) { if (!c.isEnabled()) { g.setColor(Theme.textBorderDisabledColor[Theme.style].getColor()); } else { g.setColor(Theme.textBorderColor[Theme.style].getColor()); } g.drawLine(x + 1, y + 1, x + w - 3, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + h - 3); if (!c.isEnabled()) { g.setColor(Theme.textBorderDarkDisabledColor[Theme.style].getColor()); } else { g.setColor(Theme.textBorderDarkColor[Theme.style].getColor()); } g.drawLine(x, y, x + w - 2, y); g.drawLine(x, y + 1, x, y + h - 2); g.setColor(Theme.backColor[Theme.style].getColor()); g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); if (!c.isEnabled()) { g.setColor(Theme.textBorderLightDisabledColor[Theme.style].getColor()); } else { g.setColor(Theme.textBorderLightColor[Theme.style].getColor()); } g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); g.drawLine(x + w - 1, y, x + w - 1, y + h - 1); }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(arrowColor); g.drawLine(x, y, x + 4, y); g.drawLine(x + 1, y + 1, x + 3, y + 1); g.drawLine(x + 2, y + 2, x + 2, y + 2); }
/** * Draws a simple 3d border for the given component. * * @param c The component to draw its border. * @param g The graphics context. * @param x The x coordinate of the top left corner. * @param y The y coordinate of the top left corner. * @param w The width. * @param h The height. */ public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.setColor(MetouiaLookAndFeel.getControlHighlight()); g.drawLine(0, 0, 0, h - 1); g.setColor(MetouiaLookAndFeel.getControlShadow()); g.drawLine(0, h - 1, w - 1, h - 1); }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color oldColor = g.getColor(); g.setColor(Color.BLACK); g.drawLine(x - width, y + height, x + width, y + height - 1); g.drawLine(x + width, y - height, x + width - 1, y + height - 1); g.setColor(oldColor); }
public void paintGrid(Graphics g, int rowMin, int rowMax, int colMin, int colMax) { if (!grid.getShowGrid()) { return; // do nothing } int y1 = grid.getRowPosition(rowMin); int y2 = grid.getRowPosition(rowMax) + grid.getRowHeight(rowMax); int x1 = grid.getColumnPosition(colMin); int x2 = grid.getColumnPosition(colMax) + grid.getColumnWidth(colMax); g.setColor(grid.getGridColor()); // Draw the horizontal lines for (int row = rowMin; row <= rowMax; row++) { int rowY = grid.getRowPosition(row); g.drawLine(x1, rowY, x2, rowY); } g.drawLine(x1, y2, x2, y2); // Draw the vertical gridlines for (int col = colMin; col <= colMax; col++) { int colX = grid.getColumnPosition(col); g.drawLine(colX, y1, colX, y2); } g.drawLine(x2, y1, x2, y2); }
public void paintIcon(java.awt.Component c, Graphics g, int x, int y) { Color color = c == null ? Color.GRAY : c.getBackground(); // In a compound sort, make each succesive triangle 20% // smaller than the previous one. int dx = (int) (size / 2 * Math.pow(0.8, priority)); int dy = descending ? dx : -dx; // Align icon (roughly) with font baseline. y = y + 5 * size / 6 + (descending ? -dy : 0); int shift = descending ? 1 : -1; g.translate(x, y); // Right diagonal. g.setColor(color.darker()); g.drawLine(dx / 2, dy, 0, 0); g.drawLine(dx / 2, dy + shift, 0, shift); // Left diagonal. g.setColor(color.brighter()); g.drawLine(dx / 2, dy, dx, 0); g.drawLine(dx / 2, dy + shift, dx, shift); // Horizontal line. if (descending) { g.setColor(color.darker().darker()); } else { g.setColor(color.brighter().brighter()); } g.drawLine(dx, 0, 0, 0); g.setColor(color); g.translate(-x, -y); }
protected void drawArrow(Graphics g) { this.dimension = getSize(); if (getModel().isEnabled()) { g.setColor(RapidLookTools.getColors().getSpinnerColors()[9]); } else { g.setColor(RapidLookTools.getColors().getSpinnerColors()[10]); } int baseY = (int) ((this.dimension.getHeight() / 2) - 2); if (!this.up) { baseY++; } g.translate(5, baseY); if (this.up) { g.drawLine(2, 0, 3, 0); g.drawLine(1, 1, 4, 1); g.drawLine(0, 2, 1, 2); g.drawLine(4, 2, 5, 2); } else { g.drawLine(2, 2, 3, 2); g.drawLine(1, 1, 4, 1); g.drawLine(0, 0, 1, 0); g.drawLine(4, 0, 5, 0); } g.translate(-6, -baseY); }
protected void computeGeometry() { pictHalfWidth = Width.getInt() / 2; pictWidth = pictHalfWidth + pictHalfWidth - 1; pictHeight = Height.getInt(); xLoc = -pictHalfWidth; yLoc = -pictHeight / 2; setFramesPerCycle(pictWidth - 1); setFrameIncrement(FrameIncrement.getInt()); // System.out.println("width = " + pictWidth); // System.out.println(" x = " + xLoc); // System.out.println(" y = " + yLoc); PxlColor[] ramp = AColor.getPxlColor().sinusoidalRampTo(BColor.getPxlColor(), pictHalfWidth); // System.out.println("w=" + (4*pictHalfWidth-1) + ", h=" + pictHeight); int ibWidth = 4 * pictHalfWidth - 1; if ((imageBuffer == null) || (imageBuffer.getWidth() != ibWidth) || (imageBuffer.getHeight() != pictHeight)) { imageBuffer = new BufferedImage(ibWidth, pictHeight, BufferedImage.TYPE_INT_RGB); } Graphics g = imageBuffer.getGraphics(); for (int x = 0; x < pictHalfWidth; x++) { g.setColor(ramp[x].dev()); g.drawLine(x, 0, x, pictHeight - 1); if (x < (pictHalfWidth - 1)) g.drawLine(pictWidth - x - 1, 0, pictWidth - x - 1, pictHeight - 1); if (x > 0) g.drawLine(pictWidth + x - 1, 0, pictWidth + x - 1, pictHeight - 1); if ((x > 0) && (x < (pictHalfWidth - 1))) g.drawLine(4 * pictHalfWidth - 4 - x, 0, 4 * pictHalfWidth - 4 - x, pictHeight - 1); } g.dispose(); BitMapElement p = (BitMapElement) getDisplayElement(pictElement); p.setImage(imageBuffer); p.setLocation(xLoc, yLoc); p.setClipRect(xLoc, yLoc, pictWidth, pictHeight); }
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { super.paintBorder(c, g, x, y, width, height); Insets insets = getInsets(); int space = 4; int rectSize = insets.top - space - space; int rectMinY = space; int rectMinX = width - rectSize - space - space; g.setColor(getBackground()); g.fillRect(rectMinX, rectMinY, rectSize, rectSize); g.setColor(getForeground()); g.drawRect(rectMinX, rectMinY, rectSize, rectSize); int x0 = 2; int x1 = rectSize - 2; int y0 = rectSize / 2; int y1 = rectSize / 2; g.drawLine( rectMinX + x0, rectMinY + y0, rectMinX + x1, rectMinY + y1); if (isMinimized()) { g.drawLine( rectMinX + y0, rectMinY + x0, rectMinX + y1, rectMinY + x1); } }
public void paint(Graphics g, JComponent c) { Dimension s = c.getSize(); if (WindowsMenuItemUI.isVistaPainting()) { int x = 1; Component parent = c.getParent(); if (parent instanceof JComponent) { Object gutterOffsetObject = ((JComponent) parent).getClientProperty(WindowsPopupMenuUI.GUTTER_OFFSET_KEY); if (gutterOffsetObject instanceof Integer) { /* * gutter offset is in parent's coordinates. * See comment in * WindowsPopupMenuUI.getTextOffset(JComponent) */ x = ((Integer) gutterOffsetObject).intValue() - c.getX(); x += WindowsPopupMenuUI.getGutterWidth(); } } Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR); int skinHeight = skin.getHeight(); int y = (s.height - skinHeight) / 2; skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL); } else { int y = s.height / 2; g.setColor(c.getForeground()); g.drawLine(1, y - 1, s.width - 2, y - 1); g.setColor(c.getBackground()); g.drawLine(1, y, s.width - 2, y); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { JScrollPane scroll = (JScrollPane) c; JComponent colHeader = scroll.getColumnHeader(); int colHeaderHeight = 0; if (colHeader != null) colHeaderHeight = colHeader.getHeight(); JComponent rowHeader = scroll.getRowHeader(); int rowHeaderWidth = 0; if (rowHeader != null) rowHeaderWidth = rowHeader.getWidth(); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 2, h - 2); g.setColor(MetalLookAndFeel.getControlHighlight()); g.drawLine(w - 1, 1, w - 1, h - 1); g.drawLine(1, h - 1, w - 1, h - 1); g.setColor(MetalLookAndFeel.getControl()); g.drawLine(w - 2, 2 + colHeaderHeight, w - 2, 2 + colHeaderHeight); g.drawLine(1 + rowHeaderWidth, h - 2, 1 + rowHeaderWidth, h - 2); g.translate(-x, -y); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { g.translate(x, y); if (((JToolBar) c).isFloatable()) { if (((JToolBar) c).getOrientation() == HORIZONTAL) { int shift = MetalLookAndFeel.usingOcean() ? -1 : 0; bumps.setBumpArea(10, h - 4); if (MetalUtils.isLeftToRight(c)) { bumps.paintIcon(c, g, 2, 2 + shift); } else { bumps.paintIcon(c, g, w - 12, 2 + shift); } } else // vertical { bumps.setBumpArea(w - 4, 10); bumps.paintIcon(c, g, 2, 2); } } if (((JToolBar) c).getOrientation() == HORIZONTAL && MetalLookAndFeel.usingOcean()) { g.setColor(MetalLookAndFeel.getControl()); g.drawLine(0, h - 2, w, h - 2); g.setColor(UIManager.getColor("ToolBar.borderColor")); g.drawLine(0, h - 1, w, h - 1); } g.translate(-x, -y); }
@Override public void paintOverlay(Graphics g, WidgetContainer selectedWidget) { Rectangle bounds = getPanel().getBounds(); if (selectedWidget != null) { Rectangle widgetBounds = selectedWidget.getBounds(); g.setColor(Color.GRAY); g.drawRoundRect( widgetBounds.x - 1, widgetBounds.y - 1, widgetBounds.width + 1, widgetBounds.height + 1, 8, 8); } if (useGrid) { g.setColor(GRID_COLOR); // DashboardPrefs pref = frame.getPrefs(); int[] w = {getGridCellWidth()}; // pref.grid_widths.getValue(); int[] h = {getGridCellHeight()}; // pref.grid_heights.getValue(); int cell = -1; for (int i = 0; i < bounds.width; i += w[cell = (cell + 1) % w.length]) { g.drawLine(i, 0, i, bounds.height); } cell = -1; for (int i = 0; i < bounds.height; i += h[cell = (cell + 1) % h.length]) { g.drawLine(0, i, bounds.width, i); } } }
private void drawXAxis(Graphics g, Font font) { if (!xAxis.isDisplayed()) return; Color oldColor = g.getColor(); g.setColor(Color.BLACK); float leftBorder = getLeftBorder(); int yVal = getHeight() - getNumPixelsReservedOnBottom(); g.drawLine((int) leftBorder, yVal, getWidth(), yVal); float xInterval = (getWidth() - leftBorder) / xAxis.getNumberTicks(); FontMetrics fm = g.getFontMetrics(font); for (int x = 1; x < xAxis.getNumberTicks(); x++) { float xPos = leftBorder + (xInterval * x); g.setColor(Color.GRAY); g.drawLine((int) xPos, yVal, (int) (xPos), yVal + 5); float axisValue = xAxis.getLowVal() + (x / ((float) xAxis.getNumberTicks())) * (xAxis.getHighVal() - xAxis.getLowVal()); String axisString = new String("" + (int) (axisValue + 0.5)); float tickLabelPos = xPos - fm.stringWidth(axisString) / 2; g.setColor(Color.BLACK); g.drawString(axisString, (int) tickLabelPos, yVal + 18); } g.setColor(oldColor); }
/** * Paints the graphic component * * @param g Graphic component */ public void paint(Graphics g) { if (environment != null) { Sudoku env = (Sudoku) environment; Board board = env.getBoard(); int n = SudokuLanguage.DIGITS; int sqrt_n = (int) (Math.sqrt(n) + 0.1); g.setColor(Color.lightGray); Font font = g.getFont(); g.setFont(new Font(font.getName(), font.getStyle(), 20)); for (int i = 0; i < n; i++) { int ci = getCanvasValue(i); if (i % sqrt_n == 0) { g.drawLine(ci, DRAW_AREA_SIZE + MARGIN, ci, MARGIN); g.drawLine(DRAW_AREA_SIZE + MARGIN, ci, MARGIN, ci); } for (int j = 0; j < n; j++) { int cj = getCanvasValue(j); int value = board.get(i, j); if (value > 0) { g.setColor(Color.black); g.drawString("" + value, cj + CELL_SIZE / 5, ci + CELL_SIZE); g.setColor(Color.lightGray); } } } g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN); g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN, DRAW_AREA_SIZE + MARGIN); } }
private Info Draw(Node r, int x, int y, Graphics g) { Info rootInfo = new Info(); rootInfo.xfinal = x; if (r == null) return rootInfo; Info leftInfo, rightInfo; leftInfo = Draw(r.left, x, y + 40, g); x = leftInfo.xfinal; g.drawOval(x, y, 30, 30); g.drawString("" + r.data, x + 10, y + 20); rootInfo.xroot = x; rightInfo = Draw(r.right, x + 30, y + 40, g); rootInfo.xfinal = rightInfo.xfinal; if (r.left != null) { g.drawLine(rootInfo.xroot + 5, y + 25, leftInfo.xroot + 15, y + 40); } if (r.right != null) { g.drawLine(rootInfo.xroot + 25, y + 25, rightInfo.xroot + 15, y + 40); } return rootInfo; }
private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) { int squareWidth = (int) getSize().getWidth() / model.getWidth(); int squareHeight = (int) getSize().getHeight() / model.getHeight(); Color colors[] = { new Color(0, 0, 0), new Color(204, 102, 102), new Color(102, 204, 102), new Color(102, 102, 204), new Color(204, 204, 102), new Color(204, 102, 204), new Color(102, 204, 204), new Color(218, 170, 0) }; Color color = colors[shape.ordinal()]; g.setColor(color); g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2); g.setColor(color.brighter()); g.drawLine(x, y + squareHeight - 1, x, y); g.drawLine(x, y, x + squareWidth - 1, y); g.setColor(color.darker()); g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1); g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1); }
public void drawXYAxis(Graphics g) { // x axis: (x0, yn) ~ (xn, yn) // y axis: (x0, y0) ~ (x0, yn) int x0 = Constants.CANVAS_MARGIN_WIDTH; int y0 = Constants.CANVAS_MARGIN_HEIGHT; int xn = x0 + Constants.CANVAS_WIDTH; int yn = y0 + Constants.CANVAS_HEIGHT; g.drawLine(x0, yn, xn, yn); // draw x axis g.drawLine(x0, y0, x0, yn); // draw y axis int tickInt = Constants.CANVAS_HEIGHT / 10; int min = 0; for (int xt = x0 + tickInt; xt < xn; xt += tickInt) { g.drawLine(xt, yn + 5, xt, yn - 5); // int min = (xt - x0) * (xLen / Constants.CANVAS_MARGIN_WIDTH); min += scaleUnit; g.drawString(Integer.toString(min), xt - (min < 10 ? 3 : 7), yn + 20); } // tickInt = Constants.CANVAS_HEIGHT / 10; min = 0; for (int yt = yn - tickInt; yt > Constants.CANVAS_MARGIN_HEIGHT; yt -= tickInt) { g.drawLine(x0 - 5, yt, x0 + 5, yt); // int min = (yt - y0) * (yLen / Constants.CANVAS_MARGIN_HEIGHT); min += scaleUnit; g.drawString(Integer.toString(min), x0 - 32, yt + 5); } }
// färger, se sid 43 i boken // grafiska metoder, sid 248 i boken public void paintComponent(Graphics g) { // för att vara säker på att // "super"-klassen gör sitt // anropar vi den metoden, innan // vi skriver eller ritar super.paintComponent(g); g.drawLine(185, 10, 195, 40); // x1,y1 till x2,y2 g.drawLine(200, 10, 200, 40); g.drawLine(215, 10, 205, 40); g.setColor(Color.white); g.fillOval(50, 30, 300, 150); // x,y,b,h (x,y för ö v h) g.setColor(Color.red); g.drawArc(100, 100, 200, 50, 180, 180); // x,y,b,h,s,l g.setColor(Color.yellow); g.fillRect(200, 100, 30, 30); g.fill3DRect(150, 50, 30, 50, true); // true upphöjd figur g.fill3DRect(250, 50, 30, 50, true); // skriv ut en textsträng, samt ange läget i avståndet från // övre vänstra hörnet i x-led åt höger och i y-led neråt g.drawString("** Tjenare kompis !! **", 20, 20); f = new Font("Arial", Font.BOLD, 30); setBackground(Color.cyan); g.setFont(f); g.setColor(new Color(255, 175, 175)); g.drawString("YEEEEEEEES!!", 100, 250); }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(Color.white); g.drawLine(x + 0, y + 5, x + 5, y + 0); g.drawLine(0, 5, 5, 0); System.out.println(x + "," + y); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // choose which colors we want to use Color bg = c.getBackground(); if (c.getParent() != null) { bg = c.getParent().getBackground(); } if (bg != null) { Color mid = bg.darker(); Color edge = average(mid, bg); g.setColor(bg); g.drawLine(0, h - 2, w, h - 2); g.drawLine(0, h - 1, w, h - 1); g.drawLine(w - 2, 0, w - 2, h); g.drawLine(w - 1, 0, w - 1, h); // draw the drop-shadow g.setColor(mid); g.drawLine(1, h - 2, w - 2, h - 2); g.drawLine(w - 2, 1, w - 2, h - 2); g.setColor(edge); g.drawLine(2, h - 1, w - 2, h - 1); g.drawLine(w - 1, 2, w - 1, h - 2); } }
public void drawDashedLine(int i, int j, int k, int l) { double d = 1.0D; double d1 = 4D; double d2 = java.lang.Math.sqrt((k - i) * (k - i) + (l - j) * (l - j)); if (d2 < 0.5D) { return; } double d3 = (double) (k - i) / (d2 / (d + d1)); double d4 = (double) (l - j) / (d2 / (d + d1)); double d5 = (double) (k - i) / (d2 / d); double d6 = (double) (l - j) / (d2 / d); int i1 = 0; for (double d7 = 0.0D; d7 < d2 - d; d7 += d + d1) { g.drawLine( (int) ((double) i + d3 * (double) i1), (int) ((double) j + d4 * (double) i1), (int) ((double) i + d3 * (double) i1 + d5), (int) ((double) j + d4 * (double) i1 + d6)); i1++; } if ((d + d1) * (double) i1 <= d2) { g.drawLine( (int) ((double) i + d3 * (double) i1), (int) ((double) j + d4 * (double) i1), k, l); } }
/* * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (fig instanceof OperationsCompartmentContainer) { OperationsCompartmentContainer fc = (OperationsCompartmentContainer) fig; // added by Eric Lefevre 13 Mar 1999: we must check if the // FigText for operations is drawn before drawing things // over it if (!fc.isOperationsVisible()) { fig = null; return; } Rectangle fr = fc.getOperationsBounds(); int left = fr.x + 10; int height = fr.y + fr.height - 7; int right = fr.x + fr.width - 10; g.setColor(Color.red); int i = left; while (true) { g.drawLine(i, height, i + WAVE_LENGTH, height + WAVE_HEIGHT); i += WAVE_LENGTH; if (i >= right) break; g.drawLine(i, height + WAVE_HEIGHT, i + WAVE_LENGTH, height); i += WAVE_LENGTH; if (i >= right) break; g.drawLine(i, height, i + WAVE_LENGTH, height + WAVE_HEIGHT / 2); i += WAVE_LENGTH; if (i >= right) break; g.drawLine(i, height + WAVE_HEIGHT / 2, i + WAVE_LENGTH, height); i += WAVE_LENGTH; if (i >= right) break; } fig = null; } }
protected void paintBackground(Graphics g) { int draggedColumn = -1; if ((header != null) && (header.getTable() != null) && header.getDraggedColumn() != null) { draggedColumn = header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier()); } int w = getWidth(); int h = getHeight(); if ((table != null) && table.isEnabled() && (col == rolloverCol || col == draggedColumn)) { JTattooUtilities.fillHorGradient( g, AbstractLookAndFeel.getTheme().getRolloverColors(), 0, 0, w, h); if (drawRolloverBar()) { g.setColor(AbstractLookAndFeel.getFocusColor()); g.drawLine(0, 0, w - 1, 0); g.drawLine(0, 1, w - 1, 1); g.drawLine(0, 2, w - 1, 2); } } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) { if (header.getBackground() instanceof ColorUIResource) { JTattooUtilities.fillHorGradient( g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, w, h); } else { g.setColor(header.getBackground()); g.fillRect(0, 0, w, h); } } else { if (header.getBackground() instanceof ColorUIResource) { JTattooUtilities.fillHorGradient( g, AbstractLookAndFeel.getTheme().getInActiveColors(), 0, 0, w, h); } else { g.setColor(header.getBackground()); g.fillRect(0, 0, w, h); } } }
protected void paintText(Graphics g, JComponent com, Rectangle rect, String s) { JButtonLinkA bn = (JButtonLinkA) com; ButtonModel bnModel = bn.getModel(); Color color = bn.getForeground(); Object obj = null; if (bnModel.isEnabled()) { if (bnModel.isPressed()) bn.setForeground(bn.getActiveLinkColor()); else if (bn.isLinkVisited()) bn.setForeground(bn.getVisitedLinkColor()); else bn.setForeground(bn.getLinkColor()); } else { if (bn.getDisabledLinkColor() != null) bn.setForeground(bn.getDisabledLinkColor()); } super.paintText(g, com, rect, s); int behaviour = bn.getLinkBehavior(); boolean drawLine = false; if (behaviour == JButtonLinkA.HOVER_UNDERLINE) { if (bnModel.isRollover()) drawLine = true; } else if (behaviour == JButtonLinkA.ALWAYS_UNDERLINE || behaviour == JButtonLinkA.SYSTEM_DEFAULT) drawLine = true; if (!drawLine) return; FontMetrics fm = g.getFontMetrics(); int x = rect.x + getTextShiftOffset(); int y = (rect.y + fm.getAscent() + fm.getDescent() + getTextShiftOffset()) - 1; if (bnModel.isEnabled()) { g.setColor(bn.getForeground()); g.drawLine(x, y, (x + rect.width) - 1, y); } else { g.setColor(bn.getBackground().brighter()); g.drawLine(x, y, (x + rect.width) - 1, y); } }
protected void paintComponent(Graphics g) { g.setColor(GroupedElementsRenderer.POPUP_SEPARATOR_FOREGROUND); if (hasCaption()) { Rectangle viewR = new Rectangle(0, getVgap(), getWidth() - 1, getHeight() - getVgap() - 1); Rectangle iconR = new Rectangle(); Rectangle textR = new Rectangle(); String s = SwingUtilities.layoutCompoundLabel( g.getFontMetrics(), myCaption, null, CENTER, myCaptionCentered ? CENTER : LEFT, CENTER, myCaptionCentered ? CENTER : LEFT, viewR, iconR, textR, 0); final int lineY = textR.y + textR.height / 2; if (s.equals(myCaption) && viewR.width - textR.width > 2 * getHgap()) { if (myCaptionCentered) { g.drawLine(0, lineY, textR.x - getHgap(), lineY); } g.drawLine(textR.x + textR.width + getHgap(), lineY, getWidth() - 1, lineY); } UIUtil.applyRenderingHints(g); g.setColor(GroupedElementsRenderer.POPUP_SEPARATOR_TEXT_FOREGROUND); g.drawString(s, textR.x, textR.y + g.getFontMetrics().getAscent()); } else { g.drawLine(0, getVgap(), getWidth() - 1, getVgap()); } }
private void drawAxes(Graphics g) { g.drawLine(padding, height, width + padding, height); g.drawLine(padding, 0, padding, height); g.drawString("time", padding + width / 2, height + padding - 5); g.drawString("pop", 5, height / 2); }
@SuppressWarnings("UseJBColor") @Override protected void paintComponent(Graphics g) { final Insets i = getInsets(); final Dimension d = getSize(); final int left = i.left + (d.width - i.left - i.right - WIDTH) / 2; final int top = i.top + (d.height - i.top - i.bottom - HEIGHT) / 2; g.setColor(Color.WHITE); g.fillRect(left, top, WIDTH, HEIGHT); g.setColor(Color.GRAY); g.drawLine(left + 1, i.top + HEIGHT / 2, left + WIDTH - 3, i.top + HEIGHT / 2); g.drawRect(left + 1, top + 1, WIDTH - 3, HEIGHT - 3); for (int k = 1; k < 10; k++) { g.drawLine(left + 1 + k * 31, top + 1, left + 1 + k * 31, top + HEIGHT - 3); } for (int r = 0; r < myRecentColors.size(); r++) { int row = r / 10; int col = r % 10; Color color = myRecentColors.get(r); g.setColor(color); g.fillRect(left + 2 + col * 30 + col + 1, top + 2 + row * 30 + row + 1, 28, 28); } }