Java源码示例:org.pushingpixels.substance.api.SubstanceSkin

示例1
/**
 * Opens a sample frame under the specified skin.
 * 
 * @param skin
 *            Skin.
 */
private void openSampleFrame(SubstanceSkin skin) {
    JFrame sampleFrame = new JFrame(skin.getDisplayName());
    sampleFrame.setLayout(new FlowLayout());
    JButton defaultButton = new JButton("active");
    JButton button = new JButton("default");
    JButton disabledButton = new JButton("disabled");
    disabledButton.setEnabled(false);
    sampleFrame.getRootPane().setDefaultButton(defaultButton);

    sampleFrame.add(defaultButton);
    sampleFrame.add(button);
    sampleFrame.add(disabledButton);

    sampleFrame.setVisible(true);
    sampleFrame.pack();
    sampleFrame.setLocationRelativeTo(null);
    sampleFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    sampleFrame.setIconImage(new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR));

    SubstanceCortex.RootPaneScope.setSkin(sampleFrame.getRootPane(), skin);
    SwingUtilities.updateComponentTreeUI(sampleFrame);
    sampleFrame.repaint();
}
 
示例2
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceBinaryWatermark.watermarkImage = NeonCortex.getBlankImage(screenWidth,
            screenHeight);

    Graphics2D graphics = SubstanceBinaryWatermark.watermarkImage.createGraphics();
    boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
            screenWidth, screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例3
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceLatchWatermark.watermarkImage = NeonCortex
            .getBlankImage(screenWidth, screenHeight);

    Graphics2D graphics = SubstanceLatchWatermark.watermarkImage.createGraphics();

    boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
            screenWidth, screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例4
private ResizableIcon getExpandButtonIcon(final SubstanceSkin skin,
        final AbstractCommandButton button) {
    final int fontSize = SubstanceSizeUtils.getComponentFontSize(button);
    int arrowIconWidth = (int) SubstanceSizeUtils.getSmallArrowIconWidth(fontSize);
    int arrowIconHeight = (int) SubstanceSizeUtils.getSmallDoubleArrowIconHeight(fontSize);
    final ResizableIcon arrowIcon = new TransitionAwareResizableIcon(button,
            () -> ((ActionPopupTransitionAwareUI) button.getUI()).getActionTransitionTracker(),
            (SubstanceColorScheme scheme, int width, int height) -> {
                SubstanceColorScheme bgColorScheme = skin
                        .getBackgroundColorScheme(DecorationAreaType.GENERAL);
                Color bgFillColor = bgColorScheme.getBackgroundFillColor();
                return SubstanceImageCreator.getDoubleArrowIcon(
                        width, height,
                        SubstanceSizeUtils.getSmallDoubleArrowGap(fontSize),
                        SubstanceSizeUtils.getDoubleArrowStrokeWidth(fontSize),
                        ribbonBand.getComponentOrientation().isLeftToRight()
                                ? SwingConstants.EAST : SwingConstants.WEST,
                        SubstanceColorSchemeUtilities.getShiftedScheme(scheme, bgFillColor,
                                0.0f, bgFillColor, 0.3f));
            }, new Dimension(arrowIconHeight, arrowIconWidth));
    return arrowIcon;
}
 
示例5
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
	// fix by Chris for bug 67 - support for multiple screens
	Rectangle virtualBounds = new Rectangle();
	GraphicsEnvironment ge = GraphicsEnvironment
			.getLocalGraphicsEnvironment();
	GraphicsDevice[] gds = ge.getScreenDevices();
	for (GraphicsDevice gd : gds) {
		GraphicsConfiguration gc = gd.getDefaultConfiguration();
		virtualBounds = virtualBounds.union(gc.getBounds());
	}

	int screenWidth = virtualBounds.width;
	int screenHeight = virtualBounds.height;
	SubstanceStripeWatermark.watermarkImage = SubstanceCoreUtilities
			.getBlankImage(screenWidth, screenHeight);

	Graphics2D graphics = SubstanceStripeWatermark.watermarkImage.createGraphics();

	boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
			screenWidth, screenHeight, false);
	graphics.dispose();
	return status;
}
 
示例6
/**
 * Creates a new <code>Graphite Aqua</code> skin.
 */
public GraphiteAquaSkin() {
    super(new AccentBuilder()
            .withAccentResource("org/pushingpixels/substance/api/skin/graphite.colorschemes")
            .withActiveControlsAccent("Graphite Aqua")
            .withHighlightsAccent("Graphite Aqua"));

    // Use disabled color scheme for marks of disabled selected checkboxes and radio buttons
    // for better contrast
    ColorSchemes schemes = SubstanceSkin.getColorSchemes(
            this.getClass().getClassLoader().getResourceAsStream(
                    "org/pushingpixels/substance/api/skin/graphite.colorschemes"));
    SubstanceColorScheme disabledScheme = schemes.get("Graphite Disabled");
    defaultSchemeBundle.registerColorScheme(disabledScheme,
            ColorSchemeAssociationKind.MARK, ComponentState.DISABLED_SELECTED);
}
 
示例7
/**
 * Creates a new <code>Graphite</code> skin.
 */
public GraphiteGlassSkin() {
	super();

	SubstanceSkin.ColorSchemes schemes = SubstanceSkin.getColorSchemes(
			this.getClass().getClassLoader().getResourceAsStream(
					"org/pushingpixels/substance/api/skin/graphite.colorschemes"));

	SubstanceColorScheme backgroundScheme = schemes.get("Graphite Background");
	this.registerAsDecorationArea(backgroundScheme, DecorationAreaType.PRIMARY_TITLE_PANE,
			DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER);

	// add two overlay painters to create a bezel line between
	// menu bar and toolbars
	BottomLineOverlayPainter menuOverlayPainter = new BottomLineOverlayPainter(
			ColorSchemeSingleColorQuery.MID);
	TopLineOverlayPainter toolbarOverlayPainter = new TopLineOverlayPainter(
			(SubstanceColorScheme scheme) -> SubstanceColorUtilities.getAlphaColor(
					scheme.getForegroundColor(), 32));
	this.addOverlayPainter(menuOverlayPainter, DecorationAreaType.HEADER);
	this.addOverlayPainter(toolbarOverlayPainter, DecorationAreaType.TOOLBAR);

	this.fillPainter = new GlassFillPainter();
	this.decorationPainter = new ArcDecorationPainter();
	this.highlightPainter = new GlassHighlightPainter();
}
 
示例8
@Override
public void paintOverlay(Graphics2D graphics, Component comp,
        DecorationAreaType decorationAreaType, int width, int height,
        SubstanceSkin skin) {
    Color shadowColor = SubstanceColorUtilities.deriveByBrightness(
            SubstanceColorUtilities.getBackgroundFillColor(comp), -0.4f);

    // need to handle components "embedded" in other components
    Component topMostWithSameDecorationAreaType = SubstanceCoreUtilities
            .getTopMostParentWithDecorationAreaType(comp, decorationAreaType);
    Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0),
            topMostWithSameDecorationAreaType);
    int dy = inTopMost.y;

    Graphics2D g2d = (Graphics2D) graphics.create();
    g2d.translate(0, -dy);
    g2d.setPaint(new GradientPaint(
            0, 0, SubstanceColorUtilities.getAlphaColor(shadowColor, this.startAlpha),
            0, 4, SubstanceColorUtilities.getAlphaColor(shadowColor, 16)));
    g2d.fillRect(0, 0, comp.getWidth(), 4);
    g2d.dispose();
}
 
示例9
/**
 * Paints the title background.
 * 
 * @param graphics
 *            Graphics context.
 * @param comp
 *            Component.
 * @param decorationAreaType
 *            Decoration area type. Must not be <code>null</code>.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param skin
 *            Skin for painting the title background.
 */
private void paintTitleBackground(Graphics2D graphics, Component comp,
        DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) {

    SubstanceColorScheme tileScheme = skin.getBackgroundColorScheme(decorationAreaType);
    if (this.baseDecorationPainter == null) {
        graphics.setColor(tileScheme.getMidColor());
        graphics.fillRect(0, 0, width, height);
    } else {
        this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType,
                width, height, skin);
    }

    Graphics2D temp = (Graphics2D) graphics.create();
    this.tileArea(temp, comp, tileScheme, 0, 0, width, height);
    temp.dispose();
}
 
示例10
/**
 * Paints the background of non-title decoration areas.
 * 
 * @param graphics
 *            Graphics context.
 * @param comp
 *            Component.
 * @param decorationAreaType
 *            Decoration area type. Must not be <code>null</code>.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param skin
 *            Skin for painting the background of non-title decoration areas.
 */
private void paintExtraBackground(Graphics2D graphics, Component comp,
        DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) {
    Point offset = SubstanceCoreUtilities.getOffsetInRootPaneCoords(comp);

    SubstanceColorScheme tileScheme = skin.getBackgroundColorScheme(decorationAreaType);
    if (this.baseDecorationPainter != null) {
        this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType,
                width, height, skin);
    } else {
        graphics.setColor(tileScheme.getMidColor());
        graphics.fillRect(0, 0, width, height);
    }
    Graphics2D temp = (Graphics2D) graphics.create();
    this.tileArea(temp, comp, tileScheme, offset.x, offset.y, width, height);
    temp.dispose();
}
 
示例11
@Override
public void paintDecorationArea(Graphics2D graphics, Component comp,
		DecorationAreaType decorationAreaType, int width, int height,
		SubstanceSkin skin) {
	SubstanceColorScheme scheme = skin.getBackgroundColorScheme(decorationAreaType);
	if (width * height < 100000) {
		HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height,
				scheme.getDisplayName());
		BufferedImage result = smallImageCache.get(key);
		if (result == null) {
			result = SubstanceCoreUtilities.getBlankImage(width, height);
			this.internalPaint((Graphics2D) result.getGraphics(), comp, width, height, scheme);
			smallImageCache.put(key, result);
		}
		NeonCortex.drawImage(graphics, result, 0, 0);
		return;
	}

	this.internalPaint(graphics, comp, width, height, scheme);
}
 
示例12
/**
 * Draws the specified portion of the watermark image.
 *
 * @param graphics  Graphic context.
 * @param x         the <i>x</i> coordinate of the watermark to be drawn.
 * @param y         The <i>y</i> coordinate of the watermark to be drawn.
 * @param width     The width of the watermark to be drawn.
 * @param height    The height of the watermark to be drawn.
 * @param isPreview Indication whether the result is a preview image.
 * @return Indication whether the draw succeeded.
 */
private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics,
        int x, int y, int width, int height, boolean isPreview) {
    if (isPreview) {
        // graphics.drawImage(NoiseFactory.getNoiseImage(
        // SubstanceCoreUtilities.getDefaultTheme(null)
        // .getFirstTheme().getColorScheme(),
        // SubstanceCoreUtilities.getDefaultTheme(null)
        // .getSecondTheme().getColorScheme(), width, height,
        // this.xFactor, this.yFactor, this.hasConstantZ,
        // this.noiseFilter, this.toBlur), x, y, null);
    } else {
        SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
        int alpha = scheme.isDark() ? 200 : 250;
        graphics.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, alpha / 255.0f));
        NeonCortex.drawImage(graphics, FractalFlameFactory.getFractalFlameImage(scheme,
                scheme, width, height, 25000000, this.functionSystem), x, y);
    }
    return true;
}
 
示例13
/**
 * Returns the color scheme of the specified tabbed pane tab.
 *
 * @param jtp            Tabbed pane.
 * @param tabIndex       Tab index.
 * @param componentState Tab component state.
 * @return The color scheme of the specified tabbed pane tab.
 */
public static SubstanceColorScheme getColorScheme(final JTabbedPane jtp, final int tabIndex,
        ColorSchemeAssociationKind associationKind, ComponentState componentState) {
    SubstanceSkin skin = SubstanceCoreUtilities.getSkin(jtp);
    if (skin == null) {
        SubstanceCoreUtilities.traceSubstanceApiUsage(jtp,
                "Substance delegate used when Substance is not the current LAF");
    }
    SubstanceColorScheme nonColorized = skin.getColorScheme(jtp, associationKind,
            componentState);
    if (tabIndex >= 0) {
        Component component = jtp.getComponentAt(tabIndex);
        SubstanceColorScheme colorized = getColorizedScheme(component, nonColorized,
                jtp.getForegroundAt(tabIndex), jtp.getBackgroundAt(tabIndex),
                !componentState.isDisabled());
        return colorized;
    } else {
        return getColorizedScheme(jtp, nonColorized, !componentState.isDisabled());
    }
}
 
示例14
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceCrosshatchWatermark.watermarkImage = NeonCortex.getBlankImage(screenWidth,
            screenHeight);

    Graphics2D graphics = SubstanceCrosshatchWatermark.watermarkImage.createGraphics();
    boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
            screenWidth, screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例15
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    if (font == null) {
        return false;
    }
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceKatakanaWatermark.watermarkImage = NeonCortex.getBlankImage(screenWidth,
            screenHeight);

    Graphics2D graphics = SubstanceKatakanaWatermark.watermarkImage.createGraphics();

    boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
            screenWidth, screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例16
/**
 * Invokes super implementation to uninstall any of its state. This will also reset the
 * <code>LayoutManager</code> of the <code>JRootPane</code>. If a <code>Component</code> has
 * been added to the <code>JRootPane</code> to render the window decoration style, this method
 * will remove it. Similarly, this will revert the Border and LayoutManager of the
 * <code>JRootPane</code> to what it was before <code>installUI</code> was invoked.
 * 
 * @param c
 *            the JRootPane to uninstall state from
 */
@Override
public void uninstallUI(JComponent c) {
    super.uninstallUI(c);
    this.uninstallClientDecorations(this.root);

    this.layoutManager = null;
    this.substanceMouseInputListener = null;

    if (this.root.getClientProperty(SubstanceSynapse.ROOT_PANE_SKIN) instanceof SubstanceSkin) {
        rootPanesWithCustomSkin--;
    }

    this.root = null;

    for (SubstanceWidget lafWidget : this.lafWidgets) {
        lafWidget.uninstallUI();
    }
}
 
示例17
/**
 * Paints all registered overlays on the specified component. Overlay
 * painters are registered with
 * {@link SubstanceSkin#addOverlayPainter(SubstanceOverlayPainter, DecorationAreaType...)}
 * API.
 * 
 * @param g
 *            Graphics context.
 * @param c
 *            Component.
 * @param skin
 *            Component skin.
 * @param decorationAreaType
 *            Component decoration area type.
 */
public static void paintOverlays(Graphics g, Component c,
		SubstanceSkin skin, DecorationAreaType decorationAreaType) {
	List<SubstanceOverlayPainter> overlayPainters = skin
			.getOverlayPainters(decorationAreaType);
	if (overlayPainters.size() == 0) {
		return;
	}

	for (SubstanceOverlayPainter overlayPainter : overlayPainters) {
		Graphics2D g2d = (Graphics2D) g.create();
		overlayPainter.paintOverlay(g2d, c, decorationAreaType, c
				.getWidth(), c.getHeight(), skin);
		g2d.dispose();
	}
}
 
示例18
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceBrushedMetalWatermark.watermarkImage = NeonCortex
            .getBlankImage(screenWidth, screenHeight);

    Graphics2D graphics = SubstanceBrushedMetalWatermark.watermarkImage.createGraphics();
    Composite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
    graphics.setComposite(comp);

    boolean status = this.drawWatermarkImage(graphics, 0, 0, screenWidth,
            screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例19
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceMosaicWatermark.watermarkImage = NeonCortex.getBlankImage(screenWidth, screenHeight);

    Graphics2D graphics = SubstanceMosaicWatermark.watermarkImage.createGraphics();

    boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
            screenWidth, screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例20
@Override
public boolean updateWatermarkImage(SubstanceSkin skin) {
    // fix by Chris for bug 67 - support for multiple screens
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        virtualBounds = virtualBounds.union(gc.getBounds());
    }

    int screenWidth = virtualBounds.width;
    int screenHeight = virtualBounds.height;
    SubstanceExceedWatermark.watermarkImage = NeonCortex.getBlankImage(screenWidth,
            screenHeight);

    Graphics2D graphics = SubstanceExceedWatermark.watermarkImage.createGraphics();

    boolean status = this.drawWatermarkImage(skin, graphics, 0, 0,
            screenWidth, screenHeight, false);
    graphics.dispose();
    return status;
}
 
示例21
/**
 * Synchronizes the frame icon with the current theme.
 */
protected void synchronize() {
    SwingUtilities.invokeLater(() -> {
        if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) {
            SubstanceSkin currentSkin = SubstanceCortex.ComponentScope
                    .getCurrentSkin(getRootPane());
            setFrameIcon(RadianceLogo.getLogoIcon(
                    currentSkin.getColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE,
                            ColorSchemeAssociationKind.FILL, ComponentState.ENABLED)));
            setTitle(currentSkin.getDisplayName());
        }
    });
}
 
示例22
public DestinationsPanel(Window window) {
    SubstanceSkin currentSkin = SubstanceCortex.GlobalScope.getCurrentSkin();

    ComponentOrParentChainScope.setDecorationType(this, VisorMail.DESTINATIONS);
    this.setRightLineColor(currentSkin.getColorScheme(VisorMail.DESTINATIONS,
            ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getDarkColor());
    this.setLayout(new VerticalStackLayout());

    // Get the color schemes for colorizing the icons.
    Color mainSelectorIconTitleColor = currentSkin
            .getColorScheme(VisorMail.DESTINATIONS,
                    ColorSchemeAssociationKind.FILL, ComponentState.ENABLED)
            .getForegroundColor();

    ResizableIcon refreshIcon = NeonCortex.colorizeIcon(
            ic_refresh_black_24px.factory(), mainSelectorIconTitleColor);
    refreshIcon.setDimension(new Dimension(12, 12));
    this.add(getRefreshAction(window, refreshIcon));
    this.add(getMainLabel("MAIL"));

    JList<DestinationInfo> destinationList = new JList<>(
            new DestinationListModel(
                    new DestinationInfo(ic_inbox_black_24px.factory(), "Inbox", 6),
                    new DestinationInfo(ic_send_black_24px.factory(), "Sent", 3),
                    new DestinationInfo(ic_watch_later_black_24px.factory(), "Send later", 5),
                    new DestinationInfo(ic_drafts_black_24px.factory(), "Drafts", -1),
                    new DestinationInfo(ic_star_border_black_24px.factory(), "Starred", -1),
                    new DestinationInfo(ic_delete_black_24px.factory(), "Trash", -1)));
    destinationList.setCellRenderer(new DestinationRenderer());

    destinationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    destinationList.setSelectedIndex(0);

    JScrollPane destinationScrollPane = new JScrollPane(destinationList);
    this.add(destinationScrollPane);

    this.setPreferredSize(new Dimension(200, 0));
}
 
示例23
@Override
public void drawWatermarkImage(Graphics graphics, Component c, int x,
		int y, int width, int height) {
	SubstanceSkin skin = SubstanceCoreUtilities.getSkin(c);
	Graphics2D g2d = (Graphics2D) graphics.create();
	g2d.setComposite(WidgetUtilities
			.getAlphaComposite(c, 0.2f, graphics));
	g2d.setColor(skin.getWatermarkColorScheme().getWatermarkLightColor());
	g2d.fillRect(x, y, width, height);
	g2d.dispose();
}
 
示例24
/**
 * Draws the specified portion of the watermark image.
 *
 * @param skin      Skin to use for painting the watermark.
 * @param graphics  Graphic context.
 * @param x         the <i>x</i> coordinate of the watermark to be drawn.
 * @param y         The <i>y</i> coordinate of the watermark to be drawn.
 * @param width     The width of the watermark to be drawn.
 * @param height    The height of the watermark to be drawn.
 * @param isPreview Indication whether the result is a preview image.
 * @return Indication whether the draw succeeded.
 */
private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics,
        int x, int y, int width, int height, boolean isPreview) {

    Color stampColor = null;
    int fontWidth = 0;
    int fontHeight = 0;
    SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
    if (isPreview) {
        stampColor = scheme.isDark() ? Color.white : Color.black;
        graphics.setFont(tahomaPreview);
        fontWidth = fontSize - 6;
        fontHeight = fontSize - 4;
    } else {
        stampColor = scheme.getWatermarkStampColor();
        graphics.setFont(tahoma);
        fontWidth = fontSize - 4;
        fontHeight = fontSize - 2;
    }

    graphics.setColor(stampColor);

    int rows = height / fontHeight;
    int columns = width / fontWidth;
    for (int col = x; col <= (x + columns); col++) {
        for (int row = y; row <= (y + rows); row++) {
            // choose random 0/1 letter
            double val = isPreview ? Math.abs(Math.sin((2.8 + col + columns * row)))
                    : Math.random();
            char c = (val >= 0.5) ? '0' : '1';
            graphics.drawString("" + c, col * fontWidth, fontHeight * (row + 1));
        }
    }
    return true;
}
 
示例25
/**
 * Draws the specified portion of the watermark image.
 * 
 * @param skin
 *            Skin to use for painting the watermark.
 * @param graphics
 *            Graphic context.
 * @param x
 *            the <i>x</i> coordinate of the watermark to be drawn.
 * @param y
 *            The <i>y</i> coordinate of the watermark to be drawn.
 * @param width
 *            The width of the watermark to be drawn.
 * @param height
 *            The height of the watermark to be drawn.
 * @param isPreview
 *            Indication whether the result is a preview image.
 * @return Indication whether the draw succeeded.
 */
private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics,
		int x, int y, int width, int height, boolean isPreview) {
	Color stampColor = null;
	SubstanceColorScheme scheme = skin.getWatermarkColorScheme();
	if (isPreview)
		stampColor = scheme.isDark() ? Color.lightGray : Color.darkGray;
	else {
		stampColor = scheme.getWatermarkStampColor();
	}

	double scaleFactor = NeonCortex.getScaleFactor();
	double borderStrokeWidth = 1.0f / scaleFactor;
	graphics.setColor(stampColor);
	graphics.setStroke(new BasicStroke(1.0f / (float) scaleFactor,
			BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
	double row = y;
	while (row < (y + height)) {
	    graphics.draw(new Line2D.Double(x, row, x + width, row));
	    row += 2 * borderStrokeWidth;
       }

	if (isPreview) {
		graphics.setColor(Color.gray);
           row = y + 1;
           while (row < (y + height)) {
               graphics.draw(new Line2D.Double(x, row, x + width, row));
               row += 2 * borderStrokeWidth;
           }
	}
	return true;
}
 
示例26
/**
 * Creates a new <code>Graphite</code> skin.
 */
public GraphiteSkin() {
    super(new AccentBuilder()
            .withAccentResource("org/pushingpixels/substance/api/skin/graphite.colorschemes")
.withActiveControlsAccent("Graphite Highlight")
.withHighlightsAccent("Graphite Highlight"));

    // Unlike other accented Graphite skins that use the same highlight appearance on
    // checkboxes and radio buttons as on active renderers, this skin uses a more muted
    // appearance for checkboxes and radio buttons.
    // The following sections remove the accent from those controls and use darker, less
    // vibrant appearance.
    defaultSchemeBundle.registerAlpha(0.65f, ComponentState.DISABLED_SELECTED);
    ColorSchemes schemes = SubstanceSkin.getColorSchemes(
            this.getClass().getClassLoader().getResourceAsStream(
                    "org/pushingpixels/substance/api/skin/graphite.colorschemes"));
    SubstanceColorScheme highlightMarkScheme = schemes.get("Graphite Highlight Mark");
    defaultSchemeBundle.registerColorScheme(highlightMarkScheme,
            SubstanceSlices.ColorSchemeAssociationKind.HIGHLIGHT_MARK, ComponentState.getActiveStates());
    defaultSchemeBundle.registerColorScheme(highlightMarkScheme,
            SubstanceSlices.ColorSchemeAssociationKind.MARK, ComponentState.ROLLOVER_SELECTED,
            ComponentState.ROLLOVER_UNSELECTED);

    SubstanceColorScheme selectedScheme = schemes.get("Graphite Selected");
    SubstanceColorScheme borderScheme = schemes.get("Graphite Border");
    defaultSchemeBundle.registerColorScheme(selectedScheme, ComponentState.SELECTED);
    defaultSchemeBundle.registerColorScheme(borderScheme, SubstanceSlices.ColorSchemeAssociationKind.MARK,
            ComponentState.SELECTED);

    SubstanceColorScheme selectedDisabledScheme = schemes.get("Graphite Selected Disabled");
    SubstanceColorScheme disabledScheme = schemes.get("Graphite Disabled");
    defaultSchemeBundle.registerColorScheme(disabledScheme, ComponentState.DISABLED_UNSELECTED);
    defaultSchemeBundle.registerColorScheme(selectedDisabledScheme, ComponentState.DISABLED_SELECTED);
    defaultSchemeBundle.registerColorScheme(disabledScheme, SubstanceSlices.ColorSchemeAssociationKind.MARK,
            ComponentState.DISABLED_UNSELECTED, ComponentState.DISABLED_SELECTED);
}
 
示例27
/**
 * Creates a new <code>Graphite Chalk</code> skin.
 */
public GraphiteChalkSkin() {
	SubstanceSkin.ColorSchemes schemes = SubstanceSkin.getColorSchemes(
			this.getClass().getClassLoader().getResourceAsStream(
					"org/pushingpixels/substance/api/skin/graphite.colorschemes"));

	SubstanceColorScheme chalkScheme = schemes.get("Chalk");
	defaultSchemeBundle.registerColorScheme(chalkScheme,
			ColorSchemeAssociationKind.TAB_BORDER, ComponentState.getActiveStates());
	defaultSchemeBundle.registerColorScheme(chalkScheme, ColorSchemeAssociationKind.BORDER,
			ComponentState.ENABLED);
	defaultSchemeBundle.registerColorScheme(chalkScheme, ColorSchemeAssociationKind.BORDER,
			ComponentState.getActiveStates());
	defaultSchemeBundle.registerAlpha(0.5f, ComponentState.DISABLED_UNSELECTED,
			ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_DEFAULT);
	defaultSchemeBundle.registerColorScheme(chalkScheme,
			ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_UNSELECTED,
			ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_DEFAULT);
	defaultSchemeBundle.registerColorScheme(chalkScheme,
			ColorSchemeAssociationKind.HIGHLIGHT_BORDER, ComponentState.getActiveStates());

	SubstanceColorScheme markScheme = schemes.get("Graphite Mark");
	defaultSchemeBundle.registerColorScheme(markScheme, ColorSchemeAssociationKind.MARK);

	SubstanceColorScheme separatorScheme = schemes.get("Chalk Separator");
	defaultSchemeBundle.registerColorScheme(separatorScheme,
			ColorSchemeAssociationKind.SEPARATOR, ComponentState.ENABLED);

	this.borderPainter = new ClassicBorderPainter();
}
 
示例28
/**
 * Creates a new <code>Sahara</code> skin.
 */
public SaharaSkin() {
	SubstanceColorScheme activeScheme = new DesertSandColorScheme();
	SubstanceColorScheme enabledScheme = new MetallicColorScheme();

	SubstanceSkin.ColorSchemes kitchenSinkSchemes = SubstanceSkin.getColorSchemes(
			this.getClass().getClassLoader().getResourceAsStream(
					"org/pushingpixels/substance/api/skin/kitchen-sink.colorschemes"));
	SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle(
			activeScheme, enabledScheme, kitchenSinkSchemes.get("Gray Disabled"));
	defaultSchemeBundle.registerHighlightColorScheme(
			new OliveColorScheme().shift(Color.white, 0.2f, Color.black, 0.0f).named("Sahara Highlight"));
	this.registerDecorationAreaSchemeBundle(defaultSchemeBundle,
			DecorationAreaType.NONE);

	this.registerAsDecorationArea(activeScheme,
			DecorationAreaType.PRIMARY_TITLE_PANE,
			DecorationAreaType.SECONDARY_TITLE_PANE,
			DecorationAreaType.HEADER);

	// add an overlay painter to paint a drop shadow along the top
	// edge of toolbars
	this.addOverlayPainter(TopShadowOverlayPainter.getInstance(100),
			DecorationAreaType.TOOLBAR);

	// add an overlay painter to paint separator lines along the bottom
	// edges of title panes and menu bars
	BottomLineOverlayPainter bottomLineOverlayPainter = new BottomLineOverlayPainter(
			ColorSchemeSingleColorQuery.MID);
	this.addOverlayPainter(bottomLineOverlayPainter, DecorationAreaType.HEADER);

	this.buttonShaper = new ClassicButtonShaper();
	this.fillPainter = new ClassicFillPainter();
	this.borderPainter = new ClassicBorderPainter();
	this.decorationPainter = new MatteDecorationPainter();
	this.highlightPainter = new ClassicHighlightPainter();
}
 
示例29
/**
 * Creates a new <code>Moderate</code> skin.
 */
public ModerateSkin() {
    SubstanceColorScheme activeScheme = new SteelBlueColorScheme();
    SubstanceColorScheme enabledScheme = new MetallicColorScheme();

    SubstanceSkin.ColorSchemes kitchenSinkSchemes = SubstanceSkin.getColorSchemes(
            this.getClass().getClassLoader().getResourceAsStream(
                    "org/pushingpixels/substance/api/skin/kitchen-sink.colorschemes"));
    SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle(
            activeScheme, enabledScheme, kitchenSinkSchemes.get("Gray Disabled"));
    SubstanceColorScheme highlightColorScheme = kitchenSinkSchemes.get("Moderate Highlight");
    defaultSchemeBundle.registerHighlightColorScheme(highlightColorScheme);

    this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE);

    SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle(
            activeScheme.saturate(0.2), activeScheme, kitchenSinkSchemes.get("Gray Disabled"));
    this.registerDecorationAreaSchemeBundle(headerSchemeBundle,
            DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE,
            DecorationAreaType.HEADER);

    this.registerAsDecorationArea(kitchenSinkSchemes.get("LightGray General Background"),
            DecorationAreaType.GENERAL);

    // add an overlay painter to paint a drop shadow along the top
    // edge of toolbars
    this.addOverlayPainter(TopShadowOverlayPainter.getInstance(100), DecorationAreaType.TOOLBAR);

    // add an overlay painter to paint separator lines along the bottom
    // edges of title panes and menu bars
    BottomLineOverlayPainter bottomLineOverlayPainter = new BottomLineOverlayPainter(
            ColorSchemeSingleColorQuery.MID);
    this.addOverlayPainter(bottomLineOverlayPainter, DecorationAreaType.HEADER);

    this.buttonShaper = new ClassicButtonShaper();
    this.fillPainter = new GlassFillPainter();
    this.decorationPainter = new MatteDecorationPainter();
    this.borderPainter = new ClassicBorderPainter();
    this.highlightPainter = new ClassicHighlightPainter();
}
 
示例30
@Override
public void paintDecorationArea(Graphics2D graphics, Component comp,
        DecorationAreaType decorationAreaType, int width, int height,
        SubstanceSkin skin) {
    SubstanceColorScheme colorScheme = skin.getBackgroundColorScheme(decorationAreaType);
    LinearGradientPaint paint = new LinearGradientPaint(0, 0, 0, height,
            new float[] { 0.0f, 0.4f, 0.5f, 1.0f },
            new Color[] { colorScheme.getUltraLightColor(), colorScheme.getLightColor(),
                    colorScheme.getMidColor(), colorScheme.getUltraLightColor() },
            MultipleGradientPaint.CycleMethod.REPEAT);
    graphics.setPaint(paint);
    graphics.fillRect(0, 0, width, height);
}