Java 类javax.swing.plaf.synth.SynthStyleFactory 实例源码

项目:intellij-ce-playground    文件:LafManagerImpl.java   
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) return;

  final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();

  SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
    @Override
    public SynthStyle getStyle(final JComponent c, final Region id) {
      final SynthStyle style = original.getStyle(c, id);
      if (id == Region.POPUP_MENU) {
        final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
        if (x != null && x == 0) {
          // workaround for Sun bug #6636964
          ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
          ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
        }
      }
      return style;
    }
  });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
项目:seaglass    文件:SeaGlassLookAndFeel.java   
/**
 * Called by UIManager when this look and feel is installed.
 */
@Override
public void initialize() {
    super.initialize();

    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
            @Override
            public SynthStyle getStyle(JComponent c, Region r) {
                SynthStyle style = getSeaGlassStyle(c, r);

                if (!(style instanceof SeaGlassStyle)) {
                    style = new SeaGlassStyleWrapper(style);
                }

                return style;
            }
        });
}
项目:incubator-netbeans    文件:ToolbarContainer.java   
/** Paint bumps to specific Graphics. */
@Override
public void paint (Graphics g) {
    Icon icon = UIManager.getIcon("ToolBar.handleIcon");
    Region region = Region.TOOL_BAR;
    SynthStyleFactory sf = SynthLookAndFeel.getStyleFactory();
    SynthStyle style = sf.getStyle(toolbar, region);
    SynthContext context = new SynthContext(toolbar, region, style, SynthConstants.DEFAULT);

    SynthGraphicsUtils sgu = context.getStyle().getGraphicsUtils(context);
    sgu.paintText(context, g, null, icon, SwingConstants.LEADING, SwingConstants.LEADING, 0, 0, 0, -1, 0);
}
项目:OpenJSharp    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:jdk8u-jdk    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:openjdk-jdk10    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:openjdk9    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:Java8CN    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:jdk8u_jdk    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:infobip-open-jdk-8    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:jdk8u-dev-jdk    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:jdk7-jdk    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:openjdk-source-code-learn    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:OLD-OpenJDK8    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:tools-idea    文件:LafManagerImpl.java   
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) return;

  final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();

  SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
      @Override
      public SynthStyle getStyle(final JComponent c, final Region id) {
        final SynthStyle style = original.getStyle(c, id);
        if (id == Region.POPUP_MENU) {
          try {
            Field f = style.getClass().getDeclaredField("xThickness");
            f.setAccessible(true);
            final Object x = f.get(style);
            if (x instanceof Integer && (Integer)x == 0) {
              // workaround for Sun bug #6636964
              f.set(style, 1);
              f = style.getClass().getDeclaredField("yThickness");
              f.setAccessible(true);
              f.set(style, 3);
            }
          }
          catch (Exception ignore) { }
        }
        return style;
      }
    });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
项目:openjdk-jdk7u-jdk    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:openjdk-icedtea7    文件:NimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:consulo    文件:LafManagerImpl.java   
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) return;

  final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();

  SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
    @Override
    public SynthStyle getStyle(final JComponent c, final Region id) {
      final SynthStyle style = original.getStyle(c, id);
      if (id == Region.POPUP_MENU) {
        try {
          Field f = style.getClass().getDeclaredField("xThickness");
          f.setAccessible(true);
          final Object x = f.get(style);
          if (x instanceof Integer && (Integer)x == 0) {
            // workaround for Sun bug #6636964
            f.set(style, 1);
            f = style.getClass().getDeclaredField("yThickness");
            f.setAccessible(true);
            f.set(style, 3);
          }
        }
        catch (Exception ignore) {
        }
      }
      return style;
    }
  });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
项目:JRLib    文件:OpaqueNimbusLookAndFeel.java   
/** Called by UIManager when this look and feel is installed. */
@Override public void initialize() {
    super.initialize();
    defaults.initialize();
    // create synth style factory
    setStyleFactory(new SynthStyleFactory() {
        @Override
        public SynthStyle getStyle(JComponent c, Region r) {
            return defaults.getStyle(c, r);
        }
    });
}
项目:incubator-netbeans    文件:GtkEditorTabCellRenderer.java   
private static void paintTabBackground (Graphics g, int index, int state,
int x, int y, int w, int h) {
    if (dummyTab == null) {
        dummyTab = new JTabbedPane();
    }
    Region region = Region.TABBED_PANE_TAB;
    if( !(UIManager.getLookAndFeel() instanceof SynthLookAndFeel) ) {
        return; //#215311 - unsupported L&F installed
    }
    SynthLookAndFeel laf = (SynthLookAndFeel) UIManager.getLookAndFeel();
    SynthStyleFactory sf = laf.getStyleFactory();
    SynthStyle style = sf.getStyle(dummyTab, region);
    SynthContext context =
        new SynthContext(dummyTab, region, style, 
            state == SynthConstants.FOCUSED ? SynthConstants.SELECTED : state);
    SynthPainter painter = style.getPainter(context);
    long t1, t2;
    if (state == SynthConstants.DEFAULT) {
        t1 = System.currentTimeMillis();
        painter.paintTabbedPaneTabBackground(context, g, x, y, w, h, index);
        t2 = System.currentTimeMillis();
        if ((t2 - t1) > 200) {
            LOG.log(Level.WARNING, "painter.paintTabbedPaneTabBackground1 takes too long"
            + " x=" + x + " y=" + y + " w=" + w + " h=" + h + " index:" + index
            + " Time=" + (t2 - t1));
        }
    } else {
        BufferedImage bufIm = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = bufIm.createGraphics();
        g2d.setBackground(UIManager.getColor("Panel.background"));
        g2d.clearRect(0, 0, w, h);
        t1 = System.currentTimeMillis();
        painter.paintTabbedPaneTabBackground(context, g2d, 0, 0, w, h, index);
        t2 = System.currentTimeMillis();
        if ((t2 - t1) > 200) {
            LOG.log(Level.WARNING, "painter.paintTabbedPaneTabBackground1 takes too long"
            + " x=0" + " y=0" + " w=" + w + " h=" + h + " index:" + index
            + " Time=" + (t2 - t1));
        }
        // differentiate active and selected tabs, active tab made brighter,
        // selected tab darker
        RescaleOp op = state == SynthConstants.FOCUSED 
            ? new RescaleOp(1.08f, 0, null)
            : new RescaleOp(0.96f, 0, null); 
        BufferedImage img = op.filter(bufIm, null);
        g.drawImage(img, x, y, null);
    }

}