eu.hansolo.steelseries.gauges.Linear Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SteelSeries Show documentation
Show all versions of SteelSeries Show documentation
The SteelSeries is a javabeans component library that contains gauges.
You will find linear and radial gauges. In addition you will also find
digital displays, indicators from cars and some instruments from airplanes and
sailboats.
package eu.hansolo.steelseries.gauges;
/**
*
* @author hansolo
*/
public class Linear extends AbstractLinear
{
private int tickLabelPeriod; // Draw value at every 10th tickmark
private boolean titleVisible;
private boolean unitStringVisible;
private boolean tickmarksVisible;
private java.awt.image.BufferedImage frameImage;
private java.awt.image.BufferedImage backgroundImage;
private java.awt.image.BufferedImage trackImage;
private java.awt.image.BufferedImage titleImage;
private java.awt.image.BufferedImage lcdImage;
private java.awt.image.BufferedImage tickmarksImage;
private java.awt.image.BufferedImage thresholdImage;
private java.awt.image.BufferedImage minMeasuredImage;
private java.awt.image.BufferedImage maxMeasuredImage;
private java.awt.image.BufferedImage foregroundImage;
private java.awt.image.BufferedImage disabledImage;
private final java.awt.geom.Point2D LCD_POSITION;
// Value background
private final java.awt.geom.Rectangle2D VALUE_BACKGROUND_TRACK;
private final java.awt.geom.Point2D VALUE_BACKGROUND_START;
private final java.awt.geom.Point2D VALUE_BACKGROUND_STOP;
private final float[] VALUE_BACKGROUND_TRACK_FRACTIONS;
// Value track border
private final java.awt.geom.Rectangle2D VALUE_LEFT_BORDER;
private final java.awt.geom.Rectangle2D VALUE_RIGHT_BORDER;
private final java.awt.geom.Point2D VALUE_BORDER_START;
private final java.awt.geom.Point2D VALUE_BORDER_STOP;
private final float[] VALUE_BORDER_FRACTIONS;
// The value itself
private final java.awt.geom.Rectangle2D VALUE_BACKGROUND;
private final java.awt.geom.Point2D VALUE_START;
private final java.awt.geom.Point2D VALUE_STOP;
// The lighteffect on the value
private final java.awt.geom.Rectangle2D VALUE_FOREGROUND;
private final java.awt.geom.Point2D VALUE_FOREGROUND_START;
private final java.awt.geom.Point2D VALUE_FOREGROUND_STOP;
private final float[] VALUE_FOREGROUND_FRACTIONS;
private final java.awt.Color[] VALUE_FOREGROUND_COLORS;
// Lcd related variables
private final java.awt.font.FontRenderContext RENDER_CONTEXT = new java.awt.font.FontRenderContext(null, true, true);
private double unitStringWidth;
private java.awt.font.TextLayout unitLayout;
private final java.awt.geom.Rectangle2D UNIT_BOUNDARY = new java.awt.geom.Rectangle2D.Double();
private java.awt.font.TextLayout valueLayout;
private final java.awt.geom.Rectangle2D VALUE_BOUNDARY = new java.awt.geom.Rectangle2D.Double();
public Linear()
{
super();
LCD_POSITION = new java.awt.geom.Point2D.Double();
tickLabelPeriod = 10;
titleVisible = true;
unitStringVisible = true;
tickmarksVisible = true;
VALUE_BACKGROUND_TRACK = new java.awt.geom.Rectangle2D.Double(0, 0, 10, 10);
VALUE_BACKGROUND_START = new java.awt.geom.Point2D.Double(0, 0);
VALUE_BACKGROUND_STOP = new java.awt.geom.Point2D.Double(0, 0);
VALUE_BACKGROUND_TRACK_FRACTIONS = new float[]
{
0.0f,
0.48f,
0.49f,
1.0f
};
VALUE_LEFT_BORDER = new java.awt.geom.Rectangle2D.Double(0, 0, 10, 10);
VALUE_RIGHT_BORDER = new java.awt.geom.Rectangle2D.Double(0, 0, 10, 10);
VALUE_BORDER_START = new java.awt.geom.Point2D.Double(0, 0);
VALUE_BORDER_STOP = new java.awt.geom.Point2D.Double(0, 0);
VALUE_BORDER_FRACTIONS = new float[]
{
0.0f,
0.48f,
0.49f,
1.0f
};
VALUE_BACKGROUND = new java.awt.geom.Rectangle2D.Double(0, 0, 10, 10);
VALUE_START = new java.awt.geom.Point2D.Double(0, 0);
VALUE_STOP = new java.awt.geom.Point2D.Double(0, 0);
VALUE_FOREGROUND = new java.awt.geom.Rectangle2D.Double(0, 0, 10, 10);
VALUE_FOREGROUND_START = new java.awt.geom.Point2D.Double(0, 0);
VALUE_FOREGROUND_STOP = new java.awt.geom.Point2D.Double(0, 0);
VALUE_FOREGROUND_FRACTIONS = new float[]
{
0.0f,
1.0f
};
VALUE_FOREGROUND_COLORS = new java.awt.Color[]
{
new java.awt.Color(1.0f, 1.0f, 1.0f, 0.7f),
new java.awt.Color(1.0f, 1.0f, 1.0f, 0.05f)
};
init(getInnerBounds().width, getInnerBounds().height);
}
@Override
public final AbstractGauge init(final int WIDTH, final int HEIGHT)
{
final float LCD_TEXT_HEIGHT_BASE;
if (getOrientation() == eu.hansolo.steelseries.tools.Orientation.HORIZONTAL)
{
LCD_TEXT_HEIGHT_BASE = HEIGHT * 0.15f;
}
else
{
LCD_TEXT_HEIGHT_BASE = HEIGHT * 0.055f;
}
if (isDigitalFont())
{
setLcdValueFont(LCD_DIGITAL_FONT.deriveFont(0.7f * LCD_TEXT_HEIGHT_BASE));
}
else
{
setLcdValueFont(LCD_STANDARD_FONT.deriveFont(0.625f * LCD_TEXT_HEIGHT_BASE));
}
if (getUseCustomLcdUnitFont())
{
setLcdUnitFont(getCustomLcdUnitFont().deriveFont(0.25f * LCD_TEXT_HEIGHT_BASE));
}
else
{
setLcdUnitFont(LCD_STANDARD_FONT.deriveFont(0.25f * LCD_TEXT_HEIGHT_BASE));
}
if (frameImage != null)
{
frameImage.flush();
}
frameImage = create_FRAME_Image(WIDTH, HEIGHT);
if (backgroundImage != null)
{
backgroundImage.flush();
}
backgroundImage = create_BACKGROUND_Image(WIDTH, HEIGHT);
if (trackImage != null)
{
trackImage.flush();
}
trackImage = create_TRACK_Image(WIDTH, HEIGHT, getMinValue(), getMaxValue(), getTrackStart(), getTrackSection(), getTrackStop(), getTrackStartColor(), getTrackSectionColor(), getTrackStopColor());
if (tickmarksImage != null)
{
tickmarksImage.flush();
}
tickmarksImage = create_TICKMARKS_Image(WIDTH, HEIGHT, getMinValue(), getMaxValue(), tickLabelPeriod, getScaleDividerPower(), isDrawTicks(), isDrawTickLabels(), getTickmarkSections());
if (titleImage != null)
{
titleImage.flush();
}
titleImage = create_TITLE_Image(WIDTH, HEIGHT, unitStringVisible);
if (lcdImage != null)
{
lcdImage.flush();
}
if (getOrientation() == eu.hansolo.steelseries.tools.Orientation.HORIZONTAL)
{
// Horizontal
lcdImage = create_LCD_Image((int) (WIDTH * 0.18), (int) (HEIGHT * 0.15), getLcdColor(), getCustomLcdBackground());
LCD_POSITION.setLocation((WIDTH * 0.695 + getInnerBounds().x), (getHeight() * 0.22 + getInnerBounds().y));
}
else
{
// Vertical
lcdImage = create_LCD_Image((int) (WIDTH * 0.5714285714), (int) (HEIGHT * 0.055), getLcdColor(), getCustomLcdBackground());
LCD_POSITION.setLocation(((WIDTH - lcdImage.getWidth()) / 2.0 + getInnerBounds().x), (HEIGHT * 0.88 + getInnerBounds().y));
}
if (foregroundImage != null)
{
foregroundImage.flush();
}
foregroundImage = create_FOREGROUND_Image(WIDTH, HEIGHT);
if (thresholdImage != null)
{
thresholdImage.flush();
}
thresholdImage = create_THRESHOLD_Image(WIDTH, HEIGHT);
if (minMeasuredImage != null)
{
minMeasuredImage.flush();
}
minMeasuredImage = create_MEASURED_VALUE_Image(WIDTH, HEIGHT, new java.awt.Color(0, 23, 252, 255));
if (maxMeasuredImage != null)
{
maxMeasuredImage.flush();
}
maxMeasuredImage = create_MEASURED_VALUE_Image(WIDTH, HEIGHT, new java.awt.Color(252, 29, 0, 255));
if (disabledImage != null)
{
disabledImage.flush();
}
disabledImage = create_DISABLED_Image(WIDTH, HEIGHT);
setCurrentLedImage(getLedImageOff());
return this;
}
@Override
protected void paintComponent(java.awt.Graphics g)
{
if (!isInitialized())
{
return;
}
final java.awt.Graphics2D G2 = (java.awt.Graphics2D) g.create();
G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY);
//G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE);
//G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
//G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
G2.translate(getInnerBounds().x, getInnerBounds().y);
// Draw the frame
if (isFrameVisible())
{
G2.drawImage(frameImage, 0, 0, null);
}
// Draw background
if (isBackgroundVisible())
{
G2.drawImage(backgroundImage, 0, 0, null);
}
// Draw track
if (isTrackVisible())
{
G2.drawImage(trackImage, 0, 0, null);
}
// Draw title and unit
if (isTitleVisible())
{
G2.drawImage(titleImage, 0, 0, null);
}
// Draw tickmarks
if (isTickmarksVisible())
{
G2.drawImage(tickmarksImage, 0, 0, null);
}
// Draw threshold indicator
if (isThresholdVisible())
{
final double VALUE_POS;
final java.awt.geom.AffineTransform OLD_TRANSFORM = G2.getTransform();
if (getInnerBounds().width < getInnerBounds().height)
{
// Vertical orientation
VALUE_POS = getInnerBounds().height * 0.8567961165048543 - (getInnerBounds().height * 0.7281553398) * (getThreshold() / (getMaxValue() - getMinValue())) + getInnerBounds().y;
G2.translate(getInnerBounds().width * 0.4357142857142857 - thresholdImage.getWidth() - 2 + getInnerBounds().x, VALUE_POS - thresholdImage.getHeight() / 2.0 + getInnerBounds().y);
}
else
{
// Horizontal orientation
VALUE_POS = ((getInnerBounds().width * 0.8567961165048543) - (getInnerBounds().width * 0.12864077669902912)) * getThreshold() / (getMaxValue() - getMinValue()) + getInnerBounds().x;
G2.translate(getInnerBounds().width * 0.14285714285714285 - thresholdImage.getWidth() / 2.0 + VALUE_POS + getInnerBounds().x, getHeight() * 0.5714285714 + 2 + getInnerBounds().y);
}
G2.drawImage(thresholdImage, 0, 0, null);
G2.setTransform(OLD_TRANSFORM);
}
// Draw min measured value indicator
if (isMinMeasuredValueVisible())
{
final double VALUE_POS;
final java.awt.geom.AffineTransform OLD_TRANSFORM = G2.getTransform();
if (getInnerBounds().width < getInnerBounds().height)
{
// Vertical orientation
VALUE_POS = getInnerBounds().height * 0.8567961165048543 - (getInnerBounds().height * 0.7281553398) * (getMinMeasuredValue() / (getMaxValue() - getMinValue())) + getInnerBounds().y;
G2.translate(getInnerBounds().width * 0.37 - minMeasuredImage.getWidth() - 2 + getInnerBounds().x, VALUE_POS - minMeasuredImage.getHeight() / 2.0 + getInnerBounds().y);
}
else
{
// Horizontal orientation
VALUE_POS = ((getInnerBounds().width * 0.8567961165048543) - (getInnerBounds().width * 0.12864077669902912)) * getMinMeasuredValue() / (getMaxValue() - getMinValue()) + getInnerBounds().x;
G2.translate(getInnerBounds().width * 0.14285714285714285 - minMeasuredImage.getWidth() / 2.0 + VALUE_POS + getInnerBounds().x, getInnerBounds().height * 0.63 + 2 + getInnerBounds().y);
}
G2.drawImage(minMeasuredImage, 0, 0, null);
G2.setTransform(OLD_TRANSFORM);
}
// Draw max measured value indicator
if (isMaxMeasuredValueVisible())
{
final double VALUE_POS;
final java.awt.geom.AffineTransform OLD_TRANSFORM = G2.getTransform();
if (getInnerBounds().width < getInnerBounds().height)
{
// Vertical orientation
VALUE_POS = getInnerBounds().height * 0.8567961165048543 - (getInnerBounds().height * 0.7281553398) * (getMaxMeasuredValue() / (getMaxValue() - getMinValue())) + getInnerBounds().y;
G2.translate(getInnerBounds().width * 0.37 - maxMeasuredImage.getWidth() - 2 + getInnerBounds().x, VALUE_POS - maxMeasuredImage.getHeight() / 2.0 + getInnerBounds().y);
}
else
{
// Horizontal orientation
VALUE_POS = ((getInnerBounds().width * 0.8567961165048543) - (getInnerBounds().width * 0.12864077669902912)) * getMaxMeasuredValue() / (getMaxValue() - getMinValue()) + getInnerBounds().x;
G2.translate(getInnerBounds().width * 0.14285714285714285 - maxMeasuredImage.getWidth() / 2.0 + VALUE_POS + getInnerBounds().x, getHeight() * 0.63 + 2 + getInnerBounds().y);
}
G2.drawImage(maxMeasuredImage, 0, 0, null);
G2.setTransform(OLD_TRANSFORM);
}
// Draw LED if enabled
if (isLedVisible())
{
G2.drawImage(getCurrentLedImage(), (int) (getInnerBounds().width * getLedPositionX()), (int) (getInnerBounds().height * getLedPositionY()), null);
}
// Draw LCD display
if (isLcdVisible())
{
G2.drawImage(lcdImage, (int)(LCD_POSITION.getX()), (int) (LCD_POSITION.getY()), null);
if (getLcdColor() == eu.hansolo.steelseries.tools.LcdColor.CUSTOM)
{
G2.setColor(getCustomLcdForeground());
}
else
{
G2.setColor(getLcdColor().TEXT_COLOR);
}
G2.setFont(getLcdUnitFont());
if (isLcdUnitStringVisible())
{
unitLayout = new java.awt.font.TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
G2.drawString(getLcdUnitString(), (int) (LCD_POSITION.getX() + (lcdImage.getWidth() - UNIT_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.03), (int) (LCD_POSITION.getY() + lcdImage.getHeight() * 0.76f));
unitStringWidth = UNIT_BOUNDARY.getWidth();
}
else
{
unitStringWidth = 0;
}
G2.setFont(getLcdValueFont());
valueLayout = new java.awt.font.TextLayout(formatLcdValue(getLcdValue()), G2.getFont(), RENDER_CONTEXT);
VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
G2.drawString(formatLcdValue(getLcdValue()), (int) (LCD_POSITION.getX() + (lcdImage.getWidth() - unitStringWidth - VALUE_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.09), (int) (LCD_POSITION.getY() + lcdImage.getHeight() * 0.76f));
}
// Draw value
drawValue(G2, getInnerBounds().width, getInnerBounds().height);
// Draw foreground
if (isForegroundVisible())
{
G2.drawImage(foregroundImage, 0, 0, null);
}
if (!isEnabled())
{
G2.drawImage(disabledImage, 0, 0, null);
}
G2.translate(-getInnerBounds().x, -getInnerBounds().y);
G2.dispose();
}
@Override
public void setValue(double value)
{
super.setValue(value);
if (isValueCoupled())
{
setLcdValue(value);
}
repaint(getInnerBounds());
}
public int getTickLabelPeriod()
{
return this.tickLabelPeriod;
}
public void setTickLabelPeriod(final int TICK_LABEL_PERIOD)
{
this.tickLabelPeriod = TICK_LABEL_PERIOD;
tickmarksImage = create_TICKMARKS_Image(getWidth(), getHeight(), getMinValue(), getMaxValue(), tickLabelPeriod);
repaint(getInnerBounds());
}
public boolean isTitleVisible()
{
return this.titleVisible;
}
public void setTitleVisible(final boolean TITLE_VISIBLE)
{
this.titleVisible = TITLE_VISIBLE;
repaint(getInnerBounds());
}
public boolean isTickmarksVisible()
{
return this.tickmarksVisible;
}
public void setTickmarksVisible(final boolean TICKMARKS_VISIBLE)
{
this.tickmarksVisible = TICKMARKS_VISIBLE;
repaint(getInnerBounds());
}
public boolean isUnitStringVisible()
{
return this.unitStringVisible;
}
public void setUnitStringVisible(final boolean UNIT_STRING_VISIBLE)
{
this.unitStringVisible = UNIT_STRING_VISIBLE;
init(getInnerBounds().width, getInnerBounds().height);
repaint(getInnerBounds());
}
private void drawValue(final java.awt.Graphics2D G2, final int WIDTH, final int HEIGHT)
{
final boolean VERTICAL = WIDTH < HEIGHT ? true : false;
final double TOP; // position of max value
final double BOTTOM; // position of min value
final double FULL_SIZE;
final double VALUE_SIZE;
final double VALUE_TOP;
// Orientation dependend definitions
if (VERTICAL)
{
// Vertical orientation
TOP = HEIGHT * 0.12864077669902912; // position of max value
BOTTOM = HEIGHT * 0.8567961165048543; // position of min value
FULL_SIZE = BOTTOM - TOP;
if (isStartingFromZero())
{
VALUE_SIZE = FULL_SIZE * Math.abs(getValue()) / (getMaxValue() - getMinValue());
if (getValue() < 0)
{
VALUE_TOP = TOP + FULL_SIZE - (FULL_SIZE * Math.abs(getMinValue()) / (getMaxValue() - getMinValue()));
}
else
{
VALUE_TOP = TOP + FULL_SIZE - VALUE_SIZE - (FULL_SIZE * Math.abs(getMinValue()) / (getMaxValue() - getMinValue()));
}
}
else
{
VALUE_SIZE = FULL_SIZE * (getValue() - getMinValue()) / (getMaxValue() - getMinValue());
VALUE_TOP = TOP + FULL_SIZE - VALUE_SIZE;
}
VALUE_BACKGROUND_TRACK.setRect(WIDTH * 0.4357142857142857, TOP, WIDTH * 0.14285714285714285, FULL_SIZE);
VALUE_BACKGROUND_START.setLocation(0, VALUE_BACKGROUND_TRACK.getBounds2D().getMinY() );
VALUE_BACKGROUND_STOP.setLocation(0, VALUE_BACKGROUND_TRACK.getBounds2D().getMaxY() );
}
else
{
// Horizontal orientation
TOP = WIDTH * 0.8567961165048543; // position of max value
BOTTOM = WIDTH * 0.14285714285714285; // position of min value
FULL_SIZE = TOP - WIDTH * 0.12864077669902912;
if (isStartingFromZero())
{
VALUE_SIZE = FULL_SIZE * Math.abs(getValue()) / (getMaxValue() - getMinValue());
if (getValue() < 0)
{
VALUE_TOP = BOTTOM + FULL_SIZE - VALUE_SIZE - (FULL_SIZE * Math.abs(getMinValue()) / (getMaxValue() - getMinValue()));
}
else
{
VALUE_TOP = BOTTOM + FULL_SIZE - (FULL_SIZE * Math.abs(getMinValue()) / (getMaxValue() - getMinValue()));
}
}
else
{
VALUE_SIZE = FULL_SIZE * (getValue() - getMinValue()) / (getMaxValue() - getMinValue());
VALUE_TOP = BOTTOM;
}
VALUE_BACKGROUND_TRACK.setRect(WIDTH * 0.14285714285714285, HEIGHT * 0.4357142857142857, FULL_SIZE, HEIGHT * 0.14285714285714285);
VALUE_BACKGROUND_START.setLocation(TOP, 0);
VALUE_BACKGROUND_STOP.setLocation(BOTTOM, 0);
}
final java.awt.Color[] VALUE_BACKGROUND_TRACK_COLORS =
{
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.0470588235f),
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.1450980392f),
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.1490196078f),
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.0470588235f)
};
final java.awt.LinearGradientPaint VALUE_BACKGROUND_TRACK_GRADIENT = new java.awt.LinearGradientPaint(VALUE_BACKGROUND_START, VALUE_BACKGROUND_STOP, VALUE_BACKGROUND_TRACK_FRACTIONS, VALUE_BACKGROUND_TRACK_COLORS);
G2.setPaint(VALUE_BACKGROUND_TRACK_GRADIENT);
G2.fill(VALUE_BACKGROUND_TRACK);
if (VERTICAL)
{
// Vertical orientation
VALUE_LEFT_BORDER.setRect(WIDTH * 0.4357142857142857, TOP, WIDTH * 0.007142857142857143, FULL_SIZE);
VALUE_RIGHT_BORDER.setRect(WIDTH * 0.5714285714285714, TOP, WIDTH * 0.007142857142857143, FULL_SIZE);
VALUE_BORDER_START.setLocation(0, VALUE_LEFT_BORDER.getBounds2D().getMinY() );
VALUE_BORDER_STOP.setLocation(0, VALUE_LEFT_BORDER.getBounds2D().getMaxY() );
}
else
{
// Horizontal orientation
VALUE_LEFT_BORDER.setRect(WIDTH * 0.14285714285714285, HEIGHT * 0.4357142857, FULL_SIZE, HEIGHT * 0.007142857142857143);
VALUE_RIGHT_BORDER.setRect(WIDTH * 0.14285714285714285, HEIGHT * 0.5714285714, FULL_SIZE, HEIGHT * 0.007142857142857143);
VALUE_BORDER_START.setLocation(VALUE_LEFT_BORDER.getBounds2D().getMaxX(), 0 );
VALUE_BORDER_STOP.setLocation(VALUE_LEFT_BORDER.getBounds2D().getMinX(), 0 );
}
final java.awt.Color[] VALUE_BORDER_COLORS =
{
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.2980392157f),
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.6862745098f),
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.6980392157f),
UTIL.setAlpha(getBackgroundColor().LABEL_COLOR, 0.4f)
};
final java.awt.LinearGradientPaint VALUE_BORDER_GRADIENT = new java.awt.LinearGradientPaint(VALUE_BORDER_START, VALUE_BORDER_STOP, VALUE_BORDER_FRACTIONS, VALUE_BORDER_COLORS);
G2.setPaint(VALUE_BORDER_GRADIENT);
G2.fill(VALUE_LEFT_BORDER);
G2.fill(VALUE_RIGHT_BORDER);
if (VERTICAL)
{
// Vertical orientation
VALUE_BACKGROUND.setRect(WIDTH * 0.45, VALUE_TOP, WIDTH * 0.1142857143, VALUE_SIZE);
VALUE_START.setLocation(VALUE_BACKGROUND.getBounds2D().getMinX(), 0);
VALUE_STOP.setLocation(VALUE_BACKGROUND.getBounds2D().getMaxX(), 0);
}
else
{
// Horizontal orientation
VALUE_BACKGROUND.setRect(VALUE_TOP, HEIGHT * 0.45, VALUE_SIZE, HEIGHT * 0.1142857143);
VALUE_START.setLocation(0, VALUE_BACKGROUND.getBounds2D().getMinY());
VALUE_STOP.setLocation(0, VALUE_BACKGROUND.getBounds2D().getMaxY());
}
final float[] VALUE_BACKGROUND_FRACTIONS =
{
0.0f,
0.99f,
1.0f
};
final java.awt.Color[] VALUE_BACKGROUND_COLORS;
if (getValueColor() != eu.hansolo.steelseries.tools.ColorDef.CUSTOM)
{
VALUE_BACKGROUND_COLORS = new java.awt.Color[]
{
getValueColor().MEDIUM,
getValueColor().LIGHT,
getValueColor().LIGHT
};
}
else
{
VALUE_BACKGROUND_COLORS = new java.awt.Color[]
{
getCustomValueColorObject().MEDIUM,
getCustomValueColorObject().LIGHT,
getCustomValueColorObject().LIGHT
};
}
final java.awt.LinearGradientPaint VALUE_BACKGROUND_GRADIENT = new java.awt.LinearGradientPaint(VALUE_START, VALUE_STOP, VALUE_BACKGROUND_FRACTIONS, VALUE_BACKGROUND_COLORS);
G2.setPaint(VALUE_BACKGROUND_GRADIENT);
G2.fill(VALUE_BACKGROUND);
// The lighteffect on the value
if (VERTICAL)
{
// Vertical orientation
VALUE_FOREGROUND.setRect(WIDTH * 0.45, VALUE_TOP, WIDTH * 0.05, VALUE_SIZE);
VALUE_FOREGROUND_START.setLocation(VALUE_FOREGROUND.getBounds2D().getMinX(), 0);
VALUE_FOREGROUND_STOP.setLocation(VALUE_FOREGROUND.getBounds2D().getMaxX(), 0);
}
else
{
// Horizontal orientation
VALUE_FOREGROUND.setRect(VALUE_TOP, HEIGHT * 0.45, VALUE_SIZE, HEIGHT * 0.05);
VALUE_FOREGROUND_START.setLocation(0, VALUE_FOREGROUND.getBounds2D().getMinY());
VALUE_FOREGROUND_STOP.setLocation(0, VALUE_FOREGROUND.getBounds2D().getMaxY());
}
final java.awt.LinearGradientPaint VALUE_FOREGROUND_GRADIENT = new java.awt.LinearGradientPaint(VALUE_FOREGROUND_START, VALUE_FOREGROUND_STOP, VALUE_FOREGROUND_FRACTIONS, VALUE_FOREGROUND_COLORS);
G2.setPaint(VALUE_FOREGROUND_GRADIENT);
G2.fill(VALUE_FOREGROUND);
}
private void createSections()
{
final java.awt.geom.Rectangle2D SECTION_RECTANGLE = new java.awt.geom.Rectangle2D.Double();
for (eu.hansolo.steelseries.tools.Section section : getSections())
{
switch(getOrientation())
{
case VERTICAL:
SECTION_RECTANGLE.setRect(backgroundImage.getWidth() * 0.315, backgroundImage.getHeight() * 0.1276, backgroundImage.getWidth() * 0.05, backgroundImage.getHeight() * 0.7280);
break;
case HORIZONTAL:
SECTION_RECTANGLE.setRect(backgroundImage.getWidth() * 0.139, backgroundImage.getHeight() * 0.6285714285714286, backgroundImage.getWidth() * 0.735, backgroundImage.getHeight() * 0.05);
break;
default:
SECTION_RECTANGLE.setRect(WIDTH, WIDTH, WIDTH, WIDTH);
break;
}
final java.awt.geom.Area SECTION = new java.awt.geom.Area(SECTION_RECTANGLE);
section.setSectionArea(SECTION);
}
}
@Override
protected java.awt.geom.Point2D getCenter()
{
return new java.awt.geom.Point2D.Double(backgroundImage.getWidth() / 2.0 + getInnerBounds().x, backgroundImage.getHeight() / 2.0 + getInnerBounds().y);
}
@Override
protected java.awt.geom.Rectangle2D getBounds2D()
{
return new java.awt.geom.Rectangle2D.Double(backgroundImage.getMinX(), backgroundImage.getMinY(), backgroundImage.getWidth(), backgroundImage.getHeight());
}
@Override
public String toString()
{
return "Linear";
}
}