コード例 #1
0
ファイル: SynthButtonUI.java プロジェクト: FauxFaux/jdk9-jdk
  void updateStyle(AbstractButton b) {
    SynthContext context = getContext(b, SynthConstants.ENABLED);
    SynthStyle oldStyle = style;
    style = SynthLookAndFeel.updateStyle(context, this);
    if (style != oldStyle) {
      if (b.getMargin() == null || (b.getMargin() instanceof UIResource)) {
        Insets margin = (Insets) style.get(context, getPropertyPrefix() + "margin");

        if (margin == null) {
          // Some places assume margins are non-null.
          margin = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS;
        }
        b.setMargin(margin);
      }

      Object value = style.get(context, getPropertyPrefix() + "iconTextGap");
      if (value != null) {
        LookAndFeel.installProperty(b, "iconTextGap", value);
      }

      value = style.get(context, getPropertyPrefix() + "contentAreaFilled");
      LookAndFeel.installProperty(b, "contentAreaFilled", value != null ? value : Boolean.TRUE);

      if (oldStyle != null) {
        uninstallKeyboardActions(b);
        installKeyboardActions(b);
      }
    }
  }
コード例 #2
0
ファイル: SynthListUI.java プロジェクト: GregBowyer/Hotspot
  private void updateStyle(JComponent c) {
    SynthContext context = getContext(list, ENABLED);
    SynthStyle oldStyle = style;

    style = SynthLookAndFeel.updateStyle(context, this);

    if (style != oldStyle) {
      context.setComponentState(SELECTED);
      Color sbg = list.getSelectionBackground();
      if (sbg == null || sbg instanceof UIResource) {
        list.setSelectionBackground(style.getColor(context, ColorType.TEXT_BACKGROUND));
      }

      Color sfg = list.getSelectionForeground();
      if (sfg == null || sfg instanceof UIResource) {
        list.setSelectionForeground(style.getColor(context, ColorType.TEXT_FOREGROUND));
      }

      useListColors = style.getBoolean(context, "List.rendererUseListColors", true);
      useUIBorder = style.getBoolean(context, "List.rendererUseUIBorder", true);

      int height = style.getInt(context, "List.cellHeight", -1);
      if (height != -1) {
        list.setFixedCellHeight(height);
      }
      if (oldStyle != null) {
        uninstallKeyboardActions();
        installKeyboardActions();
      }
    }
    context.dispose();
  }
コード例 #3
0
  private void updateStyle(JTable c) {
    SynthContext context = getContext(c, ENABLED);
    SynthStyle oldStyle = style;
    style = SynthLookAndFeel.updateStyle(context, this);
    if (style != oldStyle) {
      context.setComponentState(ENABLED | SELECTED);

      Color sbg = table.getSelectionBackground();
      if (sbg == null || sbg instanceof UIResource) {
        table.setSelectionBackground(style.getColor(context, ColorType.TEXT_BACKGROUND));
      }

      Color sfg = table.getSelectionForeground();
      if (sfg == null || sfg instanceof UIResource) {
        table.setSelectionForeground(style.getColor(context, ColorType.TEXT_FOREGROUND));
      }

      context.setComponentState(ENABLED);

      Color gridColor = table.getGridColor();
      if (gridColor == null || gridColor instanceof UIResource) {
        gridColor = (Color) style.get(context, "Table.gridColor");
        if (gridColor == null) {
          gridColor = style.getColor(context, ColorType.FOREGROUND);
        }
        table.setGridColor(gridColor == null ? new ColorUIResource(Color.GRAY) : gridColor);
      }

      useTableColors = style.getBoolean(context, "Table.rendererUseTableColors", true);
      useUIBorder = style.getBoolean(context, "Table.rendererUseUIBorder", true);

      Object rowHeight = style.get(context, "Table.rowHeight");
      if (rowHeight != null) {
        LookAndFeel.installProperty(table, "rowHeight", rowHeight);
      }
      boolean showGrid = style.getBoolean(context, "Table.showGrid", true);
      if (!showGrid) {
        table.setShowGrid(false);
      }
      Dimension d = table.getIntercellSpacing();
      //            if (d == null || d instanceof UIResource) {
      if (d != null) {
        d = (Dimension) style.get(context, "Table.intercellSpacing");
      }
      alternateColor = (Color) style.get(context, "Table.alternateRowColor");
      if (d != null) {
        table.setIntercellSpacing(d);
      }

      if (oldStyle != null) {
        uninstallKeyboardActions();
        installKeyboardActions();
      }
    }
    context.dispose();
  }
コード例 #4
0
  static void updateStyle(JTextComponent comp, SynthContext context, String prefix) {
    SynthStyle style = context.getStyle();

    Color color = comp.getCaretColor();
    if (color == null || color instanceof UIResource) {
      comp.setCaretColor((Color) style.get(context, prefix + ".caretForeground"));
    }

    Color fg = comp.getForeground();
    if (fg == null || fg instanceof UIResource) {
      fg = style.getColorForState(context, ColorType.TEXT_FOREGROUND);
      if (fg != null) {
        comp.setForeground(fg);
      }
    }

    Object ar = style.get(context, prefix + ".caretAspectRatio");
    if (ar instanceof Number) {
      comp.putClientProperty("caretAspectRatio", ar);
    }

    context.setComponentState(SELECTED | FOCUSED);

    Color s = comp.getSelectionColor();
    if (s == null || s instanceof UIResource) {
      comp.setSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND));
    }

    Color sfg = comp.getSelectedTextColor();
    if (sfg == null || sfg instanceof UIResource) {
      comp.setSelectedTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
    }

    context.setComponentState(DISABLED);

    Color dfg = comp.getDisabledTextColor();
    if (dfg == null || dfg instanceof UIResource) {
      comp.setDisabledTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
    }

    Insets margin = comp.getMargin();
    if (margin == null || margin instanceof UIResource) {
      margin = (Insets) style.get(context, prefix + ".margin");

      if (margin == null) {
        // Some places assume margins are non-null.
        margin = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS;
      }
      comp.setMargin(margin);
    }

    Caret caret = comp.getCaret();
    if (caret instanceof UIResource) {
      Object o = style.get(context, prefix + ".caretBlinkRate");
      if (o != null && o instanceof Integer) {
        Integer rate = (Integer) o;
        caret.setBlinkRate(rate.intValue());
      }
    }
  }
コード例 #5
0
ファイル: SynthButtonUI.java プロジェクト: FauxFaux/jdk9-jdk
  /** {@inheritDoc} */
  @Override
  protected void uninstallDefaults(AbstractButton b) {
    SynthContext context = getContext(b, ENABLED);

    style.uninstallDefaults(context);
    style = null;
  }
コード例 #6
0
ファイル: GTKStyle.java プロジェクト: susotajuraj/jdk8u-jdk
 @Override
 public void installDefaults(SynthContext context) {
   super.installDefaults(context);
   if (!context.getRegion().isSubregion()) {
     context
         .getComponent()
         .putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, GTKLookAndFeel.aaTextInfo);
   }
 }
コード例 #7
0
  private void paintDropLines(SynthContext context, Graphics g) {
    JTable.DropLocation loc = table.getDropLocation();
    if (loc == null) {
      return;
    }

    Color color = (Color) style.get(context, "Table.dropLineColor");
    Color shortColor = (Color) style.get(context, "Table.dropLineShortColor");
    if (color == null && shortColor == null) {
      return;
    }

    Rectangle rect;

    rect = getHDropLineRect(loc);
    if (rect != null) {
      int x = rect.x;
      int w = rect.width;
      if (color != null) {
        extendRect(rect, true);
        g.setColor(color);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);
      }
      if (!loc.isInsertColumn() && shortColor != null) {
        g.setColor(shortColor);
        g.fillRect(x, rect.y, w, rect.height);
      }
    }

    rect = getVDropLineRect(loc);
    if (rect != null) {
      int y = rect.y;
      int h = rect.height;
      if (color != null) {
        extendRect(rect, false);
        g.setColor(color);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);
      }
      if (!loc.isInsertRow() && shortColor != null) {
        g.setColor(shortColor);
        g.fillRect(rect.x, y, rect.width, h);
      }
    }
  }
コード例 #8
0
ファイル: SynthListUI.java プロジェクト: GregBowyer/Hotspot
  /** @inheritDoc */
  @Override
  protected void uninstallDefaults() {
    super.uninstallDefaults();

    SynthContext context = getContext(list, ENABLED);

    style.uninstallDefaults(context);
    context.dispose();
    style = null;
  }
コード例 #9
0
  /** {@inheritDoc} */
  @Override
  protected void uninstallDefaults(JScrollPane c) {
    SynthContext context = getContext(c, ENABLED);

    style.uninstallDefaults(context);

    if (scrollpane.getViewportBorder() instanceof UIResource) {
      scrollpane.setViewportBorder(null);
    }
  }
コード例 #10
0
  /** {@inheritDoc} */
  @Override
  protected void uninstallDefaults() {
    SynthContext context = getContext(getComponent(), ENABLED);

    getComponent().putClientProperty("caretAspectRatio", null);
    getComponent().removeFocusListener(handler);

    style.uninstallDefaults(context);
    style = null;
    super.uninstallDefaults();
  }
コード例 #11
0
  protected void uninstallDefaults() {
    SynthContext context = getContext(getComponent(), ENABLED);
    JComponent c = getComponent();
    c.putClientProperty("caretAspectRatio", null);

    style.uninstallDefaults(context);
    context.dispose();
    style = null;

    Object clientProperty = c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
    if (clientProperty == localTrue) {
      getComponent().putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.FALSE);
    }
    super.uninstallDefaults();
  }
コード例 #12
0
  /** {@inheritDoc} */
  @Override
  protected void uninstallDefaults() {
    table.setDefaultRenderer(Date.class, dateRenderer);
    table.setDefaultRenderer(Number.class, numberRenderer);
    table.setDefaultRenderer(Double.class, doubleRender);
    table.setDefaultRenderer(Float.class, floatRenderer);
    table.setDefaultRenderer(Icon.class, iconRenderer);
    table.setDefaultRenderer(ImageIcon.class, imageIconRenderer);
    table.setDefaultRenderer(Boolean.class, booleanRenderer);
    table.setDefaultRenderer(Object.class, objectRenderer);

    if (table.getTransferHandler() instanceof UIResource) {
      table.setTransferHandler(null);
    }
    SynthContext context = getContext(table, ENABLED);
    style.uninstallDefaults(context);
    context.dispose();
    style = null;
  }
コード例 #13
0
ファイル: SynthButtonUI.java プロジェクト: FauxFaux/jdk9-jdk
  /**
   * 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) {
    AbstractButton b = (AbstractButton) context.getComponent();

    g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
    g.setFont(style.getFont(context));
    context
        .getStyle()
        .getGraphicsUtils(context)
        .paintText(
            context,
            g,
            b.getText(),
            getIcon(b),
            b.getHorizontalAlignment(),
            b.getVerticalAlignment(),
            b.getHorizontalTextPosition(),
            b.getVerticalTextPosition(),
            b.getIconTextGap(),
            b.getDisplayedMnemonicIndex(),
            getTextShiftOffset(context));
  }
コード例 #14
0
ファイル: SynthButtonUI.java プロジェクト: FauxFaux/jdk9-jdk
 private Icon getSynthIcon(AbstractButton b, int synthConstant) {
   return style.getIcon(getContext(b, synthConstant), getPropertyPrefix() + "icon");
 }