Refine search
/** * A convenience method to return where the foreground should be painted for * the Component identified by the passed in AbstractSynthContext. * * @param state the SynthContext representing the current state. * @param insets an Insets object to be filled with the painting insets. * * @return the insets object passed in and filled with the painting insets. */ public static Insets getPaintingInsets(SynthContext state, Insets insets) { if (state.getRegion().isSubregion()) { insets = state.getStyle().getInsets(state, insets); } else { insets = state.getComponent().getInsets(insets); } return insets; }
/** * Returns a context with the given component state and all other fields same as input context. * * @param context the context, must not be null * @param state the component state. * @return a context with the given component state and other fields as inpu context. */ public static SynthContext getContext(SynthContext context, int state) { if (context.getComponentState() == state) return context; return getContext(context.getComponent(), context.getRegion(), context.getStyle(), state); }
/** * Returns a SynthContext with the specified values. * * @param component JComponent * @param region Identifies the portion of the JComponent * @param style Style associated with the component * @param state State of the component as defined in SynthConstants. * @return a SynthContext with the specified values. * * @throws NullPointerException if component, region of style is null. * */ public static SynthContext getContext(JComponent c, Region region, SynthStyle style, int state) { return new SynthContext(c, region, style, state); }
public Object getDefault(JComponent c, ComponentUI ui, String key) { if (!(ui instanceof SynthUI)) { Object value = super.getDefault(c, ui, key); return value; } SynthContext context = ((SynthUI)ui).getContext(c); Object value = context.getStyle().get(context, key); // line 27 context.dispose(); return value; }
public Dimension getPreferredSize(JComponent c) { SynthContext context = getContext(c); Dimension dim = null; if (context.getComponent().getName() == "ScrollBar.button") { //... } if (dim == null) { // For all other cases (including Spinner, ComboBox), we will // fall back on the single ArrowButton.size value to create // a square return value int size = context.getStyle().getInt(context, "ArrowButton.size", 16); dim = new Dimension(size, size); } //...
JComponent c = context.getComponent(); SynthStyle style = context.getStyle(); int x, y, width, height; x = 0; y = 0; width = c.getWidth(); height = c.getHeight(); } else { x = bounds.x; boolean subregion = context.getRegion().isSubregion(); if ((subregion && style.isOpaque(context)) || (!subregion && c.isOpaque())) { g.setColor(style.getColor(context, ColorType.BACKGROUND)); g.fillRect(x, y, width, height);
JComponent c = ss.getComponent(); FontMetrics fm = SwingUtilities2.getFontMetrics(c, g2d); Insets insets = SeaGlassLookAndFeel.getPaintingInsets(ss, paintInsets); paintViewR.width = c.getWidth() - (insets.left + insets.right); paintViewR.height = c.getHeight() - (insets.top + insets.bottom); View v = (View) c.getClientProperty(BasicHTML.propertyKey);
/** * Returns the icon's width. This is a cover methods for <code> * getIconWidth(null)</code>. * * @param context the SynthContext describing the component/region, the * style, and the state. * * @return an int specifying the fixed width of the icon. */ @Override public int getIconWidth(SynthContext context) { if (context == null) { return width; } JComponent c = context.getComponent(); if (c instanceof JToolBar && ((JToolBar) c).getOrientation() == JToolBar.VERTICAL) { // we only do the -1 hack for UIResource borders, assuming // that the border is probably going to be our border if (c.getBorder() instanceof UIResource) { return c.getWidth() - 1; } else { return c.getWidth(); } } else { return scale(context, width); } }
JComponent c = context.getComponent(); return c.getHeight() - 1; } else { return c.getHeight();
JComponent c = context.getComponent(); Region id = context.getRegion(); int cs = context.getComponentState(); return c.getBackground(); return c.getForeground(); Color color = c.getForeground(); if (!(color instanceof UIResource)) { return color;
JComponent c = ctx.getComponent(); int xstate = 0; int mask = 1; Object property = c.getClientProperty("SeaGlass.State"); return ctx.getComponentState(); int state = ctx.getComponentState();
/** * Paints the background of the thumb of a slider. * * @param context SynthContext identifying the <code>JComponent</code> * and <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to * @param orientation One of <code>JSlider.HORIZONTAL</code> or <code> * JSlider.VERTICAL</code> */ public void paintSliderThumbBackground(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) { if (context.getComponent().getClientProperty("Slider.paintThumbArrowShape") == Boolean.TRUE) { if (orientation == JSlider.HORIZONTAL) { orientation = JSlider.VERTICAL; } else { orientation = JSlider.HORIZONTAL; } paintBackground(context, g, x, y, w, h, orientation); } else { paintBackground(context, g, x, y, w, h, orientation); } }
String compName = context.getComponent().getName(); boolean ltr = context.getComponent().getComponentOrientation().isLeftToRight();
/** * Paints the border of a text field. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintTextFieldBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { if (context.getComponent().getComponentOrientation().isLeftToRight()) { paintBorder(context, g, x, y, w, h, null); } else { AffineTransform transform = new AffineTransform(); transform.translate(x, y); transform.scale(-1, 1); transform.translate(-w, 0); paintBorder(context, g, 0, 0, w, h, transform); } }
int yOffset = sortIcon == null ? 0 : (rect.height - iconHeight) / 2 - V_GAP; int x = rect.x + rect.width / 2 - (iconWidth + ARROW_TEXT_GAP + textWidth) / 2; if (shouldDisplayOnTop()) { JideSwingUtilities.drawString(c, g, str, x + ARROW_TEXT_GAP + iconWidth, rect.y + V_GAP + c.getFontMetrics(font).getAscent() - 2); if (shouldDisplayOnTop()) { if (sortIcon instanceof SynthIcon) { SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, x, rect.y + V_GAP, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + rect.width - iconWidth - textWidth - H_GAP - ARROW_TEXT_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + textWidth + H_GAP + ARROW_TEXT_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); if (shouldDisplayOnTop()) { if (sortIcon instanceof SynthIcon) { SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + rect.width / 2 - iconWidth / 2, rect.y + V_GAP, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + rect.width - iconWidth - H_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + H_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context));
/** * Returns true if the region is opaque. * * <p>Overridden to cause this style to populate itself with data from * UIDefaults, if necessary. If opacity is not specified in UI defaults, * then it defaults to being non-opaque.</p> * * @param ctx context SynthContext identifying requester * * @return true if region is opaque. */ @Override public boolean isOpaque(SynthContext ctx) { // Force Table CellRenderers to be opaque if ("Table.cellRenderer".equals(ctx.getComponent().getName())) { return true; } Boolean opaque = (Boolean) get(ctx, "opaque"); return opaque == null ? false : opaque; }
/** * Paints the specified component. * * @param context * context for the component being painted * @param g * the {@code Graphics} object used for painting * @see #update(Graphics,JComponent) */ protected void paint(SynthContext context, Graphics g) { JToolTip tip = (JToolTip) context.getComponent(); Insets insets = tip.getInsets(); View v = (View) tip.getClientProperty(BasicHTML.propertyKey); if (v != null) { Rectangle paintTextR = new Rectangle(insets.left, insets.top, tip.getWidth() - (insets.left + insets.right), tip.getHeight() - (insets.top + insets.bottom)); v.paint(g, paintTextR); } else { g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND)); g.setFont(style.getFont(context)); context.getStyle().getGraphicsUtils(context).paintText(context, g, tip.getTipText(), insets.left, insets.top, -1); } }
/** * Returns a SynthPainter from the context's style. Fall-back to default if * none available. * * @param context SynthContext containing the style, must not be null. * @return a SynthPainter from the context's style, or a default if null. */ public static SynthPainter getPainter(SynthContext context) { SynthPainter painter = context.getStyle().getPainter(context); return painter != null ? painter : NULL_PAINTER; }
if (context == null || context.getComponent() == null) { return size; String scaleKey = SeaGlassStyle.getSizeVariant(context.getComponent()); if (scaleKey != null) { if (SeaGlassStyle.LARGE_KEY.equals(scaleKey)) {