public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { if (((JToolBar) c).isFloatable()) { Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f); g2D.setComposite(alpha); if (((JToolBar) c).getOrientation() == HORIZONTAL) { if (!JTattooUtilities.isLeftToRight(c)) { x += w - 15; } g.setColor(Color.white); g.drawLine(x + 3, y + 4, x + 3, h - 5); g.drawLine(x + 6, y + 3, x + 6, h - 4); g.drawLine(x + 9, y + 4, x + 9, h - 5); g.setColor(shadow); g.drawLine(x + 4, y + 4, x + 4, h - 5); g.drawLine(x + 7, y + 3, x + 7, h - 4); g.drawLine(x + 10, y + 4, x + 10, h - 5); } else { // vertical g.setColor(Color.white); g.drawLine(x + 3, y + 3, w - 4, y + 3); g.drawLine(x + 3, y + 6, w - 4, y + 6); g.drawLine(x + 3, y + 9, w - 4, y + 9); g.setColor(shadow); g.drawLine(x + 3, y + 4, w - 4, y + 4); g.drawLine(x + 3, y + 7, w - 4, y + 7); g.drawLine(x + 3, y + 10, w - 4, y + 10); } g2D.setComposite(savedComposite); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f); g2D.setComposite(alpha); Color cHi = AbstractLookAndFeel.getTheme().getControlHighlightColor(); Color cLo = AbstractLookAndFeel.getTheme().getControlShadowColor(); JTattooUtilities.draw3DBorder(g, cHi, cLo, x, y, w, h); g2D.setComposite(savedComposite); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { Graphics2D g2D = (Graphics2D) g; Composite savedComposite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha()); g2D.setComposite(alpha); Color logoColor = AbstractLookAndFeel.getTheme().getMenuSelectionBackgroundColor(); Color borderColorLo = AbstractLookAndFeel.getFrameColor(); Color borderColorHi = ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40); g.setColor(logoColor); if (JTattooUtilities.isLeftToRight(c)) { int dx = getBorderInsets(c).left; g.fillRect(x, y, dx - 1, h - 1 - shadowSize); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + dx, y + 1, x + w - shadowSize - 2, y + 1); g.setColor(borderColorHi); g.drawLine(x + 1, y, x + 1, y + h - shadowSize - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x + dx - 1, y, x + w - shadowSize - 1, y); // left g.drawLine(x, y, x, y + h - shadowSize - 1); // bottom g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1); // right g.drawLine(x + w - shadowSize - 1, y + 1, x + w - shadowSize - 1, y + h - shadowSize - 1); } else { g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1); } // - logo separator g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - shadowSize - 1); } else { int dx = getBorderInsets(c).right - shadowSize; g.fillRect(x + w - dx - shadowSize, y, dx - 1, h - 1 - shadowSize); paintLogo(c, g, x, y, w, h); // - highlight g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40)); g.drawLine(x + 1, y + 1, x + w - dx - shadowSize - 1, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - shadowSize - 2); // - outer frame g.setColor(borderColorLo); if (isMenuBarPopup(c)) { // top g.drawLine(x, y, x + w - dx - shadowSize, y); // left g.drawLine(x, y, x, y + h - shadowSize - 1); // bottom g.drawLine(x, y + h - shadowSize - 1, x + w - shadowSize - 1, y + h - shadowSize - 1); // right g.drawLine(x + w - shadowSize - 1, y, x + w - shadowSize - 1, y + h - shadowSize - 1); } else { g.drawRect(x, y, w - shadowSize - 1, h - shadowSize - 1); } // - logo separator g.drawLine(x + w - dx - shadowSize, y + 1, x + w - dx - shadowSize, y + h - shadowSize - 1); } // paint the shadow g2D.setColor(AbstractLookAndFeel.getTheme().getShadowColor()); float alphaValue = 0.4f; for (int i = 0; i < shadowSize; i++) { alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaValue); g2D.setComposite(alpha); g.drawLine( x + w - shadowSize + i, y + shadowSize, x + w - shadowSize + i, y + h - shadowSize - 1 + i); g.drawLine( x + shadowSize, y + h - shadowSize + i, x + w - shadowSize + i, y + h - shadowSize + i); alphaValue -= (alphaValue / 2); } g2D.setComposite(savedComposite); }
public void run() { Thread me = Thread.currentThread(); while (getSize().width <= 0) { try { anim.sleep(500); } catch (InterruptedException e) { return; } } Graphics2D g2d = null; Graphics2D BufferG2D = null; Graphics2D ScreenG2D = null; BasicStroke solid = new BasicStroke(9.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 9.0f); GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO); int rule = AlphaComposite.SRC_OVER; AlphaComposite opaque = AlphaComposite.SrcOver; AlphaComposite blend = AlphaComposite.getInstance(rule, 0.9f); AlphaComposite set = AlphaComposite.Src; int frame = 0; int frametmp = 0; Dimension oldSize = getSize(); Shape clippath = null; while (anim == me) { Dimension size = getSize(); if (size.width != oldSize.width || size.height != oldSize.height) { img = null; clippath = null; if (BufferG2D != null) { BufferG2D.dispose(); BufferG2D = null; } if (ScreenG2D != null) { ScreenG2D.dispose(); ScreenG2D = null; } } oldSize = size; if (img == null) { img = (BufferedImage) createImage(size.width, size.height); } if (BufferG2D == null) { BufferG2D = img.createGraphics(); BufferG2D.setRenderingHint( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); BufferG2D.setClip(clippath); } g2d = BufferG2D; float[] ctrlpts; for (int i = 0; i < animpts.length; i += 2) { animate(animpts, deltas, i + 0, size.width); animate(animpts, deltas, i + 1, size.height); } ctrlpts = animpts; int len = ctrlpts.length; gp.reset(); int dir = 0; float prevx = ctrlpts[len - 2]; float prevy = ctrlpts[len - 1]; float curx = ctrlpts[0]; float cury = ctrlpts[1]; float midx = (curx + prevx) / 2.0f; float midy = (cury + prevy) / 2.0f; gp.moveTo(midx, midy); for (int i = 2; i <= ctrlpts.length; i += 2) { float x1 = (midx + curx) / 2.0f; float y1 = (midy + cury) / 2.0f; prevx = curx; prevy = cury; if (i < ctrlpts.length) { curx = ctrlpts[i + 0]; cury = ctrlpts[i + 1]; } else { curx = ctrlpts[0]; cury = ctrlpts[1]; } midx = (curx + prevx) / 2.0f; midy = (cury + prevy) / 2.0f; float x2 = (prevx + midx) / 2.0f; float y2 = (prevy + midy) / 2.0f; gp.curveTo(x1, y1, x2, y2, midx, midy); } gp.closePath(); g2d.setComposite(set); g2d.setBackground(backgroundColor); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); if (bgChanged || bounds == null) { bounds = new Rectangle(0, 0, getWidth(), getHeight()); bgChanged = false; } // g2d.clearRect(bounds.x-5, bounds.y-5, bounds.x + bounds.width + 5, bounds.y + bounds.height // + 5); g2d.clearRect(0, 0, getWidth(), getHeight()); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(outerColor); g2d.setComposite(opaque); g2d.setStroke(solid); g2d.draw(gp); g2d.setPaint(gradient); if (!bgChanged) { bounds = gp.getBounds(); } else { bounds = new Rectangle(0, 0, getWidth(), getHeight()); bgChanged = false; } gradient = new GradientPaint( bounds.x, bounds.y, gradientColorA, bounds.x + bounds.width, bounds.y + bounds.height, gradientColorB, true); g2d.setComposite(blend); g2d.fill(gp); if (g2d == BufferG2D) { repaint(); } ++frame; Thread.yield(); } if (g2d != null) { g2d.dispose(); } }