@Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g; Color orgColor = g2.getColor(); Object o = JideSwingUtilities.setupShapeAntialiasing(g); GeneralPath path = new GeneralPath(); if (c.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) { path.moveTo(x + 4, y); path.lineTo(x, y + 4); path.lineTo(x + 4, y + 8); } else { path.moveTo(x, y); path.lineTo(x + 4, y + 4); path.lineTo(x, y + 8); } path.closePath(); boolean rollover = _rolloverSupport.isIconRollover(x, y, getIconWidth(), getIconHeight()); g2.setColor(rollover ? COLOR_COLLAPSED_FILL_ROLLOVER : COLOR_COLLAPSED_FILL); g2.fill(path); g2.setColor(rollover ? COLOR_COLLAPSED_ROLLOVER : COLOR_COLLAPSED); g2.draw(path); g2.setColor(orgColor); JideSwingUtilities.restoreShapeAntialiasing(g, o); }
/** * Creates an RolloverIcon. * * @param rolloverSupport the IconRolloverSupport interface that should be implemented on a component. * @param iconType the icon type. It could be either {@link #ICON_EXPANDED} or {@link #ICON_COLLAPSED}. */ public RolloverIcon(IconRolloverSupport rolloverSupport, int iconType) { _rolloverSupport = rolloverSupport; switch (iconType) { case ICON_EXPANDED: _normalIcon = new DefaultExpandedIcon(rolloverSupport); break; case ICON_COLLAPSED: _normalIcon = new DefaultCollapsedIcon(rolloverSupport); break; } _rolloverIcon = null; }