javax.swing.plaf.DimensionUIResource Java Examples

The following examples show how to use javax.swing.plaf.DimensionUIResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AWTConverters.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
public void register(ConverterRegistry registry) {
  registry.addConverter(Dimension.class, String.class, this);
  registry.addConverter(String.class, Dimension.class, this);
  registry.addConverter(DimensionUIResource.class, String.class, this);

  registry.addConverter(Insets.class, String.class, this);
  registry.addConverter(String.class, Insets.class, this);
  registry.addConverter(InsetsUIResource.class, String.class, this);

  registry.addConverter(Point.class, String.class, this);
  registry.addConverter(String.class, Point.class, this);
  
  registry.addConverter(Rectangle.class, String.class, this);
  registry.addConverter(String.class, Rectangle.class, this);
  
  registry.addConverter(Font.class, String.class, this);
  registry.addConverter(FontUIResource.class, String.class, this);
}
 
Example #2
Source File: AWTConverters.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void register(ConverterRegistry registry) {
  registry.addConverter(Dimension.class, String.class, this);
  registry.addConverter(String.class, Dimension.class, this);
  registry.addConverter(DimensionUIResource.class, String.class, this);

  registry.addConverter(Insets.class, String.class, this);
  registry.addConverter(String.class, Insets.class, this);
  registry.addConverter(InsetsUIResource.class, String.class, this);

  registry.addConverter(Point.class, String.class, this);
  registry.addConverter(String.class, Point.class, this);
  
  registry.addConverter(Rectangle.class, String.class, this);
  registry.addConverter(String.class, Rectangle.class, this);
  
  registry.addConverter(Font.class, String.class, this);
  registry.addConverter(FontUIResource.class, String.class, this);
}
 
Example #3
Source File: PropertyLoader.java    From darklaf with MIT License 5 votes vote down vote up
private static Object parseSize(final String value) {
    try {
        int[] dim = Arrays.stream(value.split(String.valueOf(SEPARATOR), 2)).mapToInt(Integer::parseInt).toArray();
        return new DimensionUIResource(dim[0], dim[1]);
    } catch (IndexOutOfBoundsException | NumberFormatException e) {
        return new LoadError();
    }
}
 
Example #4
Source File: UIScale.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
public static Dimension scale( Dimension dimension ) {
	initialize();
	return (dimension == null || scaleFactor == 1f)
		? dimension
		: (dimension instanceof UIResource
			? new DimensionUIResource( scale( dimension.width ), scale( dimension.height ) )
			: new Dimension          ( scale( dimension.width ), scale( dimension.height ) ));
}
 
Example #5
Source File: UIDefaultsLoader.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
private static Dimension parseDimension( String value ) {
	List<String> numbers = split( value, ',' );
	try {
		return new DimensionUIResource(
			Integer.parseInt( numbers.get( 0 ) ),
			Integer.parseInt( numbers.get( 1 ) ) );
	} catch( NumberFormatException ex ) {
		throw new IllegalArgumentException( "invalid size '" + value + "'" );
	}
}
 
Example #6
Source File: LuckScrollUIBundle.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
protected void installOther(UIDefaults table)
{
    table.put(SCROLLBAR_WIDTH, 9);

    table.put(SCROLLBAR_BACKGROUND, getColorRes(Color.WHITE));

    table.put(MINIMUMTHUMBSIZE, new DimensionUIResource(48, 48));
}
 
Example #7
Source File: __UI__.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Ui impl.
 */
public static void uiImpl()
{
	UIManager.put("ProgressBar.background",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor));
	UIManager.put("ProgressBar.selectionForeground",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor));
	//* 此属性决定水平进度条的默认最小大小:15是相关于.9.png图片的最小填充
	//* 高度或长度的(小于此高度则NinePatch算法无法解决而很难看)
	UIManager.put("ProgressBar.horizontalSize",new DimensionUIResource(146,15));//默认是146,12
	//* 此属性决定垂直进度条的默认最小大小:15是相关于.9.png图片的最小填充
	//* 高度或长度的(小于此高度则NinePatch算法无法解决而很难看)
	UIManager.put("ProgressBar.verticalSize",new DimensionUIResource(15,146));//默认是12,146
	UIManager.put("ProgressBar.border",new BorderUIResource(BorderFactory.createEmptyBorder(0,0,0,0)));
	UIManager.put("ProgressBarUI",org.jb2011.lnf.beautyeye.ch12_progress.BEProgressBarUI.class.getName());
}
 
Example #8
Source File: ModernComboBoxUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JButton createArrowButton() {
  final Color bg = myComboBox.getBackground();
  final Color fg = myComboBox.getForeground();
  JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

    @Override
    public void paint(Graphics g) {
      Color borderColor = ModernUIUtil.getBorderColor(myComboBox);
      GraphicsConfig config = new GraphicsConfig(g);

      final int w = getWidth();
      final int h = getHeight();
      g.setColor(UIUtil.getControlColor());
      g.fillRect(0, 0, w, h - JBUI.scale(2));
      g.setColor(myComboBox.isEnabled() ? getForeground() : borderColor);
      GraphicsUtil.setupAAPainting(g);
      g.drawLine(JBUI.scale(3), JBUI.scale(7), JBUI.scale(7), JBUI.scale(11));
      g.drawLine(JBUI.scale(7), JBUI.scale(11), JBUI.scale(11), JBUI.scale(7));
      config.restore();
    }

    @Override
    public Dimension getPreferredSize() {
      int size = getFont().getSize() + JBUI.scale(4);
      if (size % 2 == 1) size += JBUI.scale(1);
      return new DimensionUIResource(size, size);
    }
  };
  button.setBorder(BorderFactory.createEmptyBorder());
  button.setOpaque(false);
  return button;
}
 
Example #9
Source File: LuckResourceBundle.java    From littleluck with Apache License 2.0 4 votes vote down vote up
protected DimensionUIResource getDimensionRes(int w, int h)
{
    return new DimensionUIResource(w, h);
}
 
Example #10
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
 * Set the icons to paint the title pane decorations.
 *
 * @param d the UI defaults map.
 */
private void defineInternalFrames(UIDefaults d) {
    
    // Copied from nimbus
    
    //Initialize InternalFrameTitlePane
    d.put("InternalFrameTitlePane.contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put("InternalFrameTitlePane.maxFrameIconSize", new DimensionUIResource(18, 18));

    //Initialize InternalFrame
    d.put("InternalFrame.contentMargins", new InsetsUIResource(1, 6, 6, 6));
    d.put("InternalFrame:InternalFrameTitlePane.contentMargins", new InsetsUIResource(3, 0, 3, 0));
    d.put("InternalFrame:InternalFrameTitlePane.titleAlignment", "CENTER");
    d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.menuButton\".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.iconifyButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9));
    d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.maximizeButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9));
    d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9));
    
    // Seaglass starts below
    
    if (PlatformUtils.isMac()) {
        d.put("frameBaseActive", new Color(0xa8a8a8));
    } else {
        d.put("frameBaseActive", new Color(0x96adc4));
    }

    d.put("frameBaseInactive", new Color(0xe0e0e0));

    d.put("frameBorderBase", new Color(0x545454));

    d.put("frameInnerHighlightInactive", new Color(0x55ffffff, true));
    d.put("frameInnerHighlightActive", new Color(0x55ffffff, true));

    d.put("seaGlassTitlePaneButtonEnabledBorder", new Color(0x99000000, true));
    d.put("seaGlassTitlePaneButtonEnabledCorner", new Color(0x26000000, true));
    d.put("seaGlassTitlePaneButtonEnabledInterior", new Color(0x99ffffff, true));

    d.put("seaGlassTitlePaneButtonHoverBorder", new Color(0xe5101010, true));
    d.put("seaGlassTitlePaneButtonHoverCorner", new Color(0x267a7a7a, true));
    d.put("seaGlassTitlePaneButtonHoverInterior", new Color(0xffffff));

    d.put("seaGlassTitlePaneButtonPressedBorder", new Color(0xe50e0e0e, true));
    d.put("seaGlassTitlePaneButtonPressedCorner", new Color(0x876e6e6e, true));
    d.put("seaGlassTitlePaneButtonPressedInterior", new Color(0xe6e6e6));

    String p = "InternalFrame";
    String c = PAINTER_PREFIX + "FrameAndRootPainter";
    
    d.put(p + ".titleFont", new DerivedFont("defaultFont", 1.0f, true, null));

    d.put(p + ".States", "Enabled,WindowFocused");
    d.put(p + ":InternalFrameTitlePane.WindowFocused", new TitlePaneWindowFocusedState());
    d.put(p + ".WindowFocused", new InternalFrameWindowFocusedState());

    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[Enabled+WindowFocused].backgroundPainter",
          new LazyPainter(c,
                          FrameAndRootPainter.Which.BACKGROUND_ENABLED_WINDOWFOCUSED));

    p = "InternalFrameTitlePane";
    d.put(p + ".buttonSpacing", 0);

    p = "InternalFrame:InternalFrameTitlePane";
    d.put(p + "[Enabled].textForeground", d.get("seaGlassDisabledText"));
    d.put(p + "[WindowFocused].textForeground", Color.BLACK);
}
 
Example #11
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the progress bar settings.
 *
 * @param d the UI defaults map.
 */
private void defineProgressBars(UIDefaults d) {
    // Copied from nimbus

  //Initialize ProgressBar
    d.put("ProgressBar.contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put("ProgressBar.States", "Enabled,Disabled,Indeterminate,Finished");
    d.put("ProgressBar.tileWhenIndeterminate", Boolean.TRUE);
    d.put("ProgressBar.paintOutsideClip", Boolean.TRUE);
    d.put("ProgressBar.rotateText", Boolean.TRUE);
    d.put("ProgressBar.vertictalSize", new DimensionUIResource(19, 150));
    d.put("ProgressBar.horizontalSize", new DimensionUIResource(150, 19));
    addColor(d, "ProgressBar[Disabled].textForeground", "seaGlassDisabledText", 0.0f, 0.0f, 0.0f, 0);
    d.put("ProgressBar[Disabled+Indeterminate].progressPadding", new Integer(3));
    
    // Seaglass starts below.
    
    d.put("progressBarTrackInterior", Color.WHITE);
    d.put("progressBarTrackBase", new Color(0x4076bf));

    d.put("ProgressBar.Indeterminate", new ProgressBarIndeterminateState());
    d.put("ProgressBar.Finished", new ProgressBarFinishedState());

    String p = "ProgressBar";
    String c = PAINTER_PREFIX + "ProgressBarPainter";

    d.put(p + ".cycleTime", 500);
    d.put(p + ".progressPadding", new Integer(3));
    d.put(p + ".trackThickness", new Integer(19));
    d.put(p + ".tileWidth", new Integer(24));
    d.put(p + ".backgroundFillColor", Color.WHITE);
    d.put(p + ".font", new DerivedFont("defaultFont", 0.769f, null, null));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ProgressBarPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ProgressBarPainter.Which.BACKGROUND_DISABLED));
    d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_ENABLED));
    d.put(p + "[Enabled+Finished].foregroundPainter",
          new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_ENABLED_FINISHED));
    d.put(p + "[Enabled+Indeterminate].foregroundPainter",
          new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_ENABLED_INDETERMINATE));
    d.put(p + "[Disabled].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_DISABLED));
    d.put(p + "[Disabled+Finished].foregroundPainter",
          new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_DISABLED_FINISHED));
    d.put(p + "[Disabled+Indeterminate].foregroundPainter",
          new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_DISABLED_INDETERMINATE));
}
 
Example #12
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the scroll bar UI settings.
 *
 * @param d the UI defaults map.
 */
private void defineScrollBars(UIDefaults d) {
    d.put("scrollBarThumbBorderBasePressed", new Color(0x4879bf));
    d.put("scrollBarThumbInteriorBasePressed", new Color(0x82a8ca));
    d.put("scrollBarButtonBase", Color.WHITE);
    d.put("scrollBarButtonBasePressed", new Color(0xa1bfdb));
    d.put("scrollBarTrackBackgroundBase", Color.WHITE);
    d.put("scrollBarTrackGradientBase", d.get("seaGlassTransparent"));

    d.put("ScrollBar.incrementButtonGap", new Integer(-7));
    d.put("ScrollBar.decrementButtonGap", new Integer(-7));
    d.put("ScrollBar.capSize", new Integer(11));
    d.put("ScrollBar.contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put("ScrollBar.thumbHeight", new Integer(15));
    d.put("ScrollBar.minimumThumbSize", new DimensionUIResource(29, 29));
    d.put("ScrollBar.maximumThumbSize", new DimensionUIResource(1000, 1000));

    // Buttons
    String c = PAINTER_PREFIX + "ScrollBarButtonPainter";
    String p = "ScrollBar:\"ScrollBar.button\"";
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".size", new Integer(22));
    
    d.put(p + ".States", "Enabled,Pressed,MouseOver,IncreaseButton,Disabled,ButtonsTogether");
    d.put(p + ".IncreaseButton", new ScrollBarButtonIsIncreaseButtonState());
    d.put(p + ".ButtonsTogether", new ScrollBarButtonsTogetherState());
    d.put(p + ".foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED));
    d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED));
    d.put(p + "[Disabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_DISABLED));
    d.put(p + "[MouseOver].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED));
    d.put(p + "[Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_PRESSED));
    d.put(p + "[MouseOver+Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_PRESSED));
    d.put(p + "[IncreaseButton+Enabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_ENABLED));
    d.put(p + "[MouseOver+IncreaseButton].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_ENABLED));
    d.put(p + "[IncreaseButton+Disabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_DISABLED));
    d.put(p + "[IncreaseButton+Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_PRESSED));
    d.put(p + "[MouseOver+IncreaseButton+Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_PRESSED));
    d.put(p + "[Enabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED_TOGETHER));
    d.put(p + "[Disabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_DISABLED_TOGETHER));
    d.put(p + "[Pressed+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_PRESSED_TOGETHER));
    d.put(p + "[IncreaseButton+Enabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_ENABLED_TOGETHER));
    d.put(p + "[IncreaseButton+Disabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_DISABLED_TOGETHER));
    d.put(p + "[IncreaseButton+Pressed+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_PRESSED_TOGETHER));

    // Thumb
    // Seems to be a bug somewhere where MouseOver is always delivered even
    // when we don't want it, but if it's not specified nothing at all is
    // painted.
    c = PAINTER_PREFIX + "ScrollBarThumbPainter";
    p = "ScrollBar:ScrollBarThumb";
    d.put(p + ".States", "Enabled,Pressed,MouseOver,Disabled");
    d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_DISABLED));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[MouseOver].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_PRESSED));
    d.put(p + "[MouseOver+Pressed].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_PRESSED));

    // Track
    c = PAINTER_PREFIX + "ScrollBarTrackPainter";
    p = "ScrollBar:ScrollBarTrack";
    d.put(p + ".States", "Enabled,Disabled");
    d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ScrollBarTrackPainter.Which.BACKGROUND_DISABLED));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ScrollBarTrackPainter.Which.BACKGROUND_ENABLED));

    // Cap
    c = PAINTER_PREFIX + "ScrollBarButtonPainter";
    p = "ScrollBar:ScrollBarCap";
    d.put(p + ".States", "Enabled,Disabled");
    d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_CAP));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_CAP));
}
 
Example #13
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
     * Initialize the table UI settings.
     *
     * @param d the UI defaults map.
     */
    private void defineTables(UIDefaults d) {
        d.put("tableHeaderBorderEnabled", new Color(0xcad3e0));
        d.put("tableHeaderSortIndicator", new Color(0xc02a5481, true));
        // Rossi: table headers now blue and glassy.
        // I know you discussed this already but I like all interactive components to have the glassy look.
        d.put("tableHeaderInteriorBaseEnabled", new Color(0x80a6d2));

        String p = "TableHeader";
        String c = PAINTER_PREFIX + "TableHeaderPainter";

//        d.put(p + ".font", new DerivedFont("defaultFont", 0.846f, null, null));
        d.put(p + "[Enabled].ascendingSortIconPainter", new LazyPainter(c, TableHeaderPainter.Which.ASCENDINGSORTICON_ENABLED));
        d.put(p + "[Enabled].descendingSortIconPainter", new LazyPainter(c, TableHeaderPainter.Which.DESCENDINGSORTICON_ENABLED));

        p = "Table";
        d.put(p + ".background", new ColorUIResource(Color.WHITE));
        d.put(p + ".alternateRowColor", new ColorUIResource(0xebf5fc));
        d.put(p + ".showGrid", Boolean.FALSE);
        d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
        d.put(p + ".opaque", Boolean.TRUE);
        d.put(p + ".intercellSpacing", new DimensionUIResource(0, 0));
        d.put(p + ".rendererUseTableColors", Boolean.TRUE);
        d.put(p + ".rendererUseUIBorder", Boolean.TRUE);
        d.put(p + ".cellNoFocusBorder", new BorderUIResource(BorderFactory.createEmptyBorder(2, 5, 2, 5)));

        // TODO Why doesn't ColorUIResource work on these next two?
        d.put(p + "[Enabled+Selected].textForeground", Color.WHITE);
        d.put(p + "[Enabled+Selected].textBackground", new Color(0x6181a5));
        d.put(p + "[Disabled+Selected].textBackground", new Color(0x6181a5));
        d.put(p + ".ascendingSortIcon", new SeaGlassIcon("TableHeader", "ascendingSortIconPainter", 8, 7));
        d.put(p + ".descendingSortIcon", new SeaGlassIcon("TableHeader", "descendingSortIconPainter", 8, 7));
        d.put(p + ".scrollPaneCornerComponent", TableScrollPaneCorner.class);
        
        c = PAINTER_PREFIX + "TableHeaderRendererPainter";
        p = "TableHeader:\"TableHeader.renderer\"";
        d.put(p + ".contentMargins", new InsetsUIResource(2, 4, 2, 4));
        d.put(p + ".States", "Enabled,Pressed,Disabled,Focused,Sorted");
        d.put(p + ".Sorted", new TableHeaderRendererSortedState());
        d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_DISABLED));
        d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED));
        d.put(p + "[Enabled+Focused].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED_FOCUSED));
        d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_PRESSED));
        d.put(p + "[Enabled+Sorted].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED_SORTED));
        d.put(p + "[Enabled+Focused+Sorted].backgroundPainter",
              new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED_FOCUSED_SORTED));
        d.put(p + "[Disabled+Sorted].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_DISABLED_SORTED));
    }
 
Example #14
Source File: DarculaComboBoxUI.java    From Darcula with Apache License 2.0 4 votes vote down vote up
protected JButton createArrowButton() {
  final Color bg = myComboBox.getBackground();
  final Color fg = myComboBox.getForeground();
  JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

    @Override
    public void paint(Graphics g2) {
      final Graphics2D g = (Graphics2D)g2;
      final GraphicsConfig config = new GraphicsConfig(g);

      final int w = getWidth();
      final int h = getHeight();
      if (!isTableCellEditor(myComboBox)) {
        g.setColor(getArrowButtonFillColor(UIUtil.getControlColor()));
        g.fillRect(0, 0, w, h);
      }
      g.setColor(comboBox.isEnabled() ? new DoubleColor(Gray._255, getForeground()) : new DoubleColor(Gray._255, getForeground().darker()));
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
      g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
      final int xU = w / 4;
      final int yU = h / 4;
      final Path2D.Double path = new Path2D.Double();
      g.translate(2, 0);
      path.moveTo(xU + 1, yU + 2);
      path.lineTo(3 * xU + 1, yU + 2);
      path.lineTo(2 * xU + 1, 3 * yU);
      path.lineTo(xU + 1, yU + 2);
      path.closePath();
      g.fill(path);
      g.translate(-2, 0);
      if (!isTableCellEditor(myComboBox)) {
        g.setColor(getArrowButtonFillColor(getBorderColor()));
        g.drawLine(0, -1, 0, h);
      }
      config.restore();
    }

    @Override
    public Dimension getPreferredSize() {
      int size = getFont().getSize() + 4;
      if (size%2==1) size++;
      return new DimensionUIResource(size, size);
    }
  };
  button.setBorder(BorderFactory.createEmptyBorder());
  button.setOpaque(false);
  return button;
}
 
Example #15
Source File: DarculaComboBoxUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JButton createArrowButton() {
  final Color bg = myComboBox.getBackground();
  final Color fg = myComboBox.getForeground();
  JButton button = new DPIAwareArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

    @Override
    public void paint(Graphics g2) {
      final Graphics2D g = (Graphics2D)g2;
      final GraphicsConfig config = new GraphicsConfig(g);

      final int w = getWidth();
      final int h = getHeight();
      g.setColor(UIManager.getColor("ComboBox.background"));
      g.fillRect(0, 0, w, h);
      g.setColor(myComboBox.isEnabled() ? getForeground() : getForeground().darker());
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
      g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
      final int xU = w / 4;
      final int yU = h / 4;
      final Path2D.Double path = new Path2D.Double();
      g.translate(0, 0);
      path.moveTo(xU + JBUI.scale(1), yU + JBUI.scale(2));
      path.lineTo(3 * xU + JBUI.scale(1), yU + JBUI.scale(2));
      path.lineTo(2 * xU + JBUI.scale(1), 3 * yU);
      path.lineTo(xU + JBUI.scale(1), yU + JBUI.scale(2));
      path.closePath();
      g.fill(path);
      g.translate(0, 0);
      g.setColor(getBorderColor());
      g.drawLine(0, -JBUI.scale(1), 0, h);
      config.restore();
    }

    @Override
    public Dimension getPreferredSize() {
      int size = getFont().getSize() + 4;
      if (size % 2 == 1) size++;
      return new DimensionUIResource(size, size);
    }
  };
  button.setBorder(BorderFactory.createEmptyBorder());
  button.setOpaque(false);
  return button;
}