📄 bluecurveengine.java
字号:
/* * @(#)BluecurveEngine.java 1.6 04/01/09 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.java.swing.plaf.gtk;import javax.swing.plaf.synth.*;import java.awt.*;import javax.swing.*;import javax.swing.plaf.*;/** * A bluecurve like engine. * * @version 1.6, 01/09/04 * @author Scott Violet */class BluecurveEngine extends GTKEngine { public void paintSlider(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h, int orientation) { Region region = context.getRegion(); if (region == Region.SLIDER_THUMB) { BluecurveStyle style = (BluecurveStyle)context.getStyle(); JComponent c = context.getComponent(); paintBackground(context, g, state, style.getGTKColor( c, region, state, GTKColorType.BACKGROUND), x, y, w, h); g.setColor(style.getGTKColor(c, region, state, BluecurveColorType.OUTER3)); g.drawLine(x + 2, y, x + w - 3, y); g.drawLine(x, y + 2, x, y + h - 3); g.drawLine(x + w - 1, y + 2, x + w - 1, y + h - 3); g.drawLine(x + 2, y + h - 1, x + w - 3, y + h - 1); g.fillRect(x + 1, y + 1, 1, 1); g.fillRect(x + w - 2, y + 1, 1, 1); g.fillRect(x + 1, y + h - 2, 1, 1); g.fillRect(x + w - 2, y + h - 2, 1, 1); g.setColor(style.getGTKColor(c, region, state, BluecurveColorType.WHITE)); g.drawLine(x + 2, y + 1, x + w - 3, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + h - 3); g.setColor(style.getGTKColor(c, region, state, BluecurveColorType.INNER_RIGHT2)); g.drawLine(x + 2, y + h - 2, x + w - 3, y + h - 2); g.drawLine(x + w - 2, y + 2, x + w - 2, y + h - 3); g.drawLine(x, y + 1, x + 1, y); g.drawLine(x, y + h - 2, x + 1, y + h - 1); g.drawLine(x + w - 2, y + h - 1, x + w - 1, y + h - 2); g.drawLine(x + w - 2, y, x + w - 1, y + 1); if (((JSlider)c).getOrientation() == SwingConstants.HORIZONTAL && w > 12) { paintHash(context, g, state, x + w / 2 - 5, y + h / 2 - 2, 3); paintHash(context, g, state, x + w / 2 - 3, y + h / 2 - 3, 6); paintHash(context, g, state, x + w / 2 +2, y + h / 2 - 1, 3); } else if (((JSlider)c).getOrientation() == SwingConstants.VERTICAL && h > 12) { paintHash(context, g, state, x + w / 2 - 2, y + h / 2 - 5, 3); paintHash(context, g, state, x + w / 2 - 3, y + h / 2 - 3, 6); paintHash(context, g, state, x + w / 2 - 1, y + h / 2 + 2, 3); } } else { super.paintSlider(context, g, state, shadowType, info, x, y, w, h, orientation); if (context.getRegion() == Region.SCROLL_BAR_THUMB) { paintHashes(context, g, state, x, y, w, h, orientation, 3, 5); } } } private void paintHash(SynthContext context, Graphics g, int state, int x, int y, int size) { GTKStyle style = (GTKStyle)context.getStyle(); g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, BluecurveColorType.OUTER2)); g.drawLine(x, y + size, x + size, y); g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, GTKColorType.WHITE)); g.drawLine(x + 1, y + size, x + size, y + 1); } private void paintHashes(SynthContext context, Graphics g, int state, int x, int y, int w, int h, int orientation, int count, int size) { // 3 diagonal lines 5x5 GTKStyle style = (GTKStyle)context.getStyle(); if (orientation == GTKConstants.HORIZONTAL) { if (w < size * count + 4) { return; } int x0 = x + (w - size * count) / 2; int y0 = y + (h - size) / 2; g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, BluecurveColorType.OUTER2)); for (int counter = 0; counter < count; counter++) { g.drawLine(x0 + counter * size, y0 + size, x0 + (counter + 1) * size, y0); } g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, GTKColorType.WHITE)); for (int counter = 0; counter < count; counter++) { g.drawLine(x0 + counter * size + 1, y0 + size, x0 + (counter + 1) * size, y0 + 1); } } else if (orientation == GTKConstants.VERTICAL) { if (h < size * count + 4) { return; } int x0 = x + (w - size) / 2; int y0 = y + (h - size * count) / 2; g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, BluecurveColorType.OUTER2)); for (int counter = 0; counter < count; counter++) { g.drawLine(x0, y0 + (counter + 1) * size, x0 + size, y0 + (counter * size)); } g.setColor(style.getGTKColor(context.getComponent(), context.getRegion(), state, GTKColorType.WHITE)); for (int counter = 0; counter < count; counter++) { g.drawLine(x0 + 1, y0 + (counter + 1) * size, x0 + size, y0 + counter * size + 1); } } } public void paintBox(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h) { GTKStyle style = (GTKStyle)context.getStyle(); Region region = context.getRegion(); if (info != "trough" || region != Region.SLIDER_TRACK) { paintBackground(context, g, state, style.getGTKColor(context.getComponent(), region, state, GTKColorType.BACKGROUND), x, y, w, h); } paintShadow(context, g, state, shadowType, info, x, y, w, h); } public void paintShadow(SynthContext context, Graphics g, int state, int shadowType, String info, int x, int y, int w, int h) { if (info == "menubar") { // This isn't really dark, but not sure what color they're using // here g.setColor(((GTKStyle)context.getStyle()).getGTKColor( context.getComponent(), context.getRegion(), state, BluecurveColorType.OUTER4)); g.drawLine(x, y + h - 1, x + w, y + h - 1); return; } if (info == "buttondefault") { // YES, this appears to be special cased. g.setColor(((GTKStyle)context.getStyle()).getGTKColor( context.getComponent(), context.getRegion(), state, GTKColorType.BLACK)); g.drawRect(x, y, w - 1, h - 1); return; } BluecurveStyle style = (BluecurveStyle)context.getStyle(); JComponent c = context.getComponent(); Region region = context.getRegion(); int xThickness = style.getXThickness(); int yThickness = style.getYThickness(); if (info == "trough") { // YES, this appears to be special cased. xThickness = yThickness = 1; if (region == Region.SLIDER_TRACK) { if (((JSlider)c).getOrientation() ==SwingConstants.HORIZONTAL){ if (h > 5) { y = y + h / 2 - 2; h = 5; } } else if (w > 5) { x = x + w / 2 - 2; w = 5; } } } else if (info == "bar") { if (xThickness < 2) { x -= xThickness; y -= yThickness; w += xThickness + xThickness; h += yThickness + yThickness; xThickness = yThickness = 2; } } if (xThickness < 0 && yThickness < 0) { // nothing to paint. return; } Color upperLeft = null, innerLeft = null, bottomRight = null, innerRight = null; if (info == "menu" || (info == "trough" && (region == Region.PROGRESS_BAR || region == Region.SLIDER_TRACK)) || info == "entry") { if (info != "menu" && info != "entry") { g.setColor(style.getGTKColor(c, region, state, BluecurveColorType.OUTER4)); g.fillRect(x, y, w, h); } upperLeft = bottomRight = style.getGTKColor(c, region, state, BluecurveColorType.OUTER2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -