Commit 02acec73 authored by Valérie Maquil's avatar Valérie Maquil

several alternatives for the steelseries gauges

parent a7e6378f
......@@ -8,6 +8,7 @@ BUILDER_CLASS_POSTFIX=Builder
CENTRE_NODE=centre
CENTRED_NODE=centred
COLOUR_NODE=colour
COLOURSC_NODE=colourscheme
CORONA_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.corona.builder
CORONA_NODE=corona
CORONAS_NODE=coronas
......@@ -52,12 +53,14 @@ SCALE_NODE=scale
SECTION_NODE=section
SECTIONS_NODE=sections
SHAPE_NODE=shape
SOUND_NODE=sound
SPACE=\
SPIN_ON_CORONA_CENTRE_NODE=spinOnCoronaCentre
START_NODE=start
STATE_NODE=state
STEP_SIZE_NODE=stepSize
STOP_NODE=stop
STYLE_NODE=style
TEXT_NODE=text
TITLE_NODE=title
TRIGGER_CONDITION_NODE=triggerCondition
......
......@@ -72,7 +72,8 @@
<dependency>
<groupId>eu.hansolo</groupId>
<artifactId>SteelSeries</artifactId>
<version>3.9</version>
<version>3.9.30</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -32,6 +32,7 @@ import org.eclipse.osgi.util.NLS;
@SuppressWarnings("javadoc")
public class Externalization extends NLS {
private static final String BUNDLE_NAME = "externalization"; //$NON-NLS-1$
public static String ALPHA_NODE;
public static String BACKGROUND_COLOUR_NODE;
public static String BASE_VALUE_NODE;
......@@ -42,6 +43,7 @@ public class Externalization extends NLS {
public static String CENTRE_NODE;
public static String CENTRED_NODE;
public static String COLOUR_NODE;
public static String COLOURSC_NODE;
public static String CORONA_BUILDER_NAMESPACE;
public static String CORONA_NODE;
public static String CORONAS_NODE;
......@@ -86,12 +88,14 @@ public class Externalization extends NLS {
public static String SECTION_NODE;
public static String SECTIONS_NODE;
public static String SHAPE_NODE;
public static String SOUND_NODE;
public static String SPACE;
public static String SPIN_ON_CORONA_CENTRE_NODE;
public static String START_NODE;
public static String STATE_NODE;
public static String STEP_SIZE_NODE;
public static String STOP_NODE;
public static String STYLE_NODE;
public static String TEXT_NODE;
public static String TITLE_NODE;
public static String TRIGGER_CONDITION_NODE;
......@@ -106,6 +110,8 @@ public class Externalization extends NLS {
public static String Y_NODE;
public static String Z_NODE;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Externalization.class);
......
......@@ -31,20 +31,27 @@ import java.util.List;
import eu.hansolo.steelseries.gauges.AbstractRadial;
import eu.hansolo.steelseries.gauges.Radial;
import eu.hansolo.steelseries.tools.FrameType;
import eu.hansolo.steelseries.gauges.Radial2Top;
import eu.hansolo.steelseries.gauges.RadialBargraph;
import eu.hansolo.steelseries.tools.BackgroundColor;
import eu.hansolo.steelseries.tools.Section;
import eu.hansolo.steelseries.tools.TickmarkType;
/**
* @author nico Mack [nico.mack@list.lu]
* @author Nico Mack [nico.mack@list.lu]
* @author Eric Tobias [eric.tobias@list.lu]
* @author Valrie Maquil [valerie.maquil@list.lu]
* @date 27 Apr 2015
* @since 2.2
* @version 2.3.0
*/
public class Gauge extends Corona implements InformationReceiver<Double> {
AbstractRadial gauge;
int width;
int height;
int style;
int colourscheme;
BufferedImage rendered;
double scale;
List<Section> sections;
......@@ -56,18 +63,96 @@ public class Gauge extends Corona implements InformationReceiver<Double> {
height = (int) builder.height;
sections = builder.sections;
scale = builder.scale;
style = builder.style;
colourscheme = builder.colourscheme;
rendered = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
gauge = new Radial();
switch (style) {
case 0: {
gauge = new Radial();
break;
}
case 1: {
gauge = new Radial();
break;
}
case 2: {
gauge = new RadialBargraph();
break;
}
case 3: {
gauge = new Radial2Top();
break;
}
}
gauge.setMinValue(builder.lowerBound);
gauge.setMaxValue(builder.upperBound);
gauge.setFrameType(FrameType.ROUND);
// gauge.setFrameType(FrameType.ROUND);
gauge.setTitle(builder.title);
gauge.setUnitString(builder.unit);
gauge.setLedVisible(false);
gauge.setLcdVisible(false);
gauge.setFrameVisible(false);
switch (colourscheme) {
case 0: { // dark (default)
break;
}
case 1: { // black
gauge.setBackgroundColor(BackgroundColor.BLACK);
break;
}
case 2: { // white
gauge.setBackgroundColor(BackgroundColor.WHITE);
break;
}
}
switch (style) {
case 0: {
gauge.setForegroundVisible(false);
break;
}
case 1: { // simple radial
gauge.setForegroundVisible(false);
gauge.setMinorTickmarkVisible(false);
gauge.setMajorTickmarkType(TickmarkType.CIRCLE);
gauge.setMinorTickmarkType(TickmarkType.CIRCLE);
break;
}
case 2: { // bargraph
gauge.setForegroundVisible(false);
gauge.setMinorTickmarkVisible(false);
gauge.setMajorTickmarkVisible(false);
// sections.add(new Section(0, 0, Color.YELLOW));
break;
}
case 3: { // radial2top
gauge.setForegroundVisible(false);
gauge.setMinorTickmarkVisible(false);
gauge.setMajorTickmarkType(TickmarkType.CIRCLE);
gauge.setMinorTickmarkType(TickmarkType.CIRCLE);
break;
}
}
// sections.add(new Section(0, 100, Color.RED));
if (sections != null) {
gauge.setSectionsVisible(true);
gauge.setSections(sections.toArray(new Section[sections.size()]));
......@@ -83,6 +168,7 @@ public class Gauge extends Corona implements InformationReceiver<Double> {
return;
Graphics2D offscreen = rendered.createGraphics();
// TODO: should this be set to -width and -height?
gauge.setLocation(0, 0);
gauge.paint(offscreen);
......@@ -92,7 +178,7 @@ public class Gauge extends Corona implements InformationReceiver<Double> {
Point drawAt = centre.add(initialTranslation);
AffineTransform rotation = new AffineTransform();
rotation.translate(drawAt.x, drawAt.y);
rotation.translate(drawAt.x - width / 2, drawAt.y - height / 2);
if (this.isStatic()) {
rotation.rotate(drawAt.getAngle(), -initialTranslation.x, -initialTranslation.y);
......
......@@ -51,6 +51,8 @@ public class GaugeBuilder extends CoronaBuilder<GaugeBuilder> {
public String title;
public String unit;
public List<Section> sections = new ArrayList<>();
public int style;
public int colourscheme;
/**
......@@ -85,6 +87,13 @@ public class GaugeBuilder extends CoronaBuilder<GaugeBuilder> {
} catch (NumberFormatException nfe) {
throw new BuildException("The provided values for width, height, both bounds, and the scale need to be double (large floating point) values!", nfe); //$NON-NLS-1$
}
try {
style = Integer.parseInt(rootElement.getChildText(Externalization.STYLE_NODE));
colourscheme = Integer.parseInt(rootElement.getChildText(Externalization.COLOURSC_NODE));
} catch (NumberFormatException nfe) {
style = 0;
colourscheme = 0;
}
title = rootElement.getChildText(Externalization.TITLE_NODE);
unit = rootElement.getChildText(Externalization.UNIT_NODE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment