Commit ca1b3ee2 authored by Eric Tobias's avatar Eric Tobias

Added Gauge Corona and its builder. Added SteelSeries library to POM

parent ea2e45ce
......@@ -55,5 +55,10 @@
<artifactId>org.eclipse.osgi</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>eu.hansolo</groupId>
<artifactId>SteelSeries</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -32,7 +32,7 @@ import java.lang.reflect.InvocationTargetException;
/**
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.2
* @version 2.2.0
* @version 2.2.1
*/
public class CoronaBootstrapper {
......@@ -60,8 +60,11 @@ public class CoronaBootstrapper {
* @throws InstantiationException
* Thrown if the class that declares the underlying constructor represents an abstract
* class.
* @throws BuildException
* Thrown if building the corona did not succeed due to an internal error such as a
* violation of precondition(s) or unavailable but required resources.
*/
private static Corona getCorona(Element coronaNode) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
private static Corona getCorona(Element coronaNode) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException, BuildException {
Element type = coronaNode.getChild(Externalization.TYPE_NODE);
Class<?> builder = Class.forName(Externalization.CORONA_BUILDER_NAMESPACE + Externalization.NAMESPACE_SEPARATOR + type.getValue() + Externalization.BUILDER_CLASS_POSTFIX);
@SuppressWarnings("unchecked")
......
......@@ -39,7 +39,8 @@ public class TangibleApplicationBootstrapper extends TangibleApplication {
public TangibleApplicationBootstrapper(@Nullable String newPropertiesFileUri) throws BuildException {
super(newPropertiesFileUri);
objectManager = new TangibleObjectBootstrapper(this, logger, properties, properties.getProperty("bootstrapping.root", "config/bootstrapping.xml")); //$NON-NLS-1$ //$NON-NLS-2$
objectManager = new TangibleObjectBootstrapper(this, logger, properties, properties.getProperty("bootstrapping.root", "bootstrapping.xml")); //$NON-NLS-1$ //$NON-NLS-2$
objectManager.defineWidgets();
adapter.setObjectManager(objectManager);
// TODO Initialize Content Manager (or leave it null)
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.widget.corona;
import lu.list.itis.dkd.tui.content.InformationReceiver;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.corona.builder.GaugeBuilder;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
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.tools.Section;
/**
* @author nmack
* @author Eric Tobias [eric.tobias@list.lu]
* @date 27 Apr 2015
*
*/
public class Gauge extends Corona implements InformationReceiver<Double> {
AbstractRadial gauge;
int width;
int height;
BufferedImage rendered;
double scale;
List<Section> sections;
public Gauge(GaugeBuilder builder) {
super(builder);
width = (int) builder.width;
height = (int) builder.height;
sections = builder.sections;
gauge = new Radial();
gauge.setMinValue(builder.lowerBound);
gauge.setMaxValue(builder.upperBound);
gauge.setFrameType(FrameType.ROUND);
gauge.setVisible(true);
gauge.setSize(width, height);
gauge.setTitle(builder.title);
gauge.setUnitString(builder.unit);
gauge.setLedVisible(false);
if (sections != null) {
gauge.setSectionsVisible(true);
Section[] sectionArray = new Section[sections.size()];
int index = 0;
for (Section section : sections) {
sectionArray[index++] = section;
}
gauge.setSections(sectionArray);
}
this.scale = builder.scale;
rendered = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}
@Override
public void paint(Graphics2D canvas) {
if (!active)
return;
Graphics2D offscreen = rendered.createGraphics();
gauge.setLocation(0, 0);
gauge.paint(offscreen);
centre.toScreenCoordinates();
if (initialTranslation != null)
initialTranslation.toScreenCoordinates();
Point drawAt = centre.add(initialTranslation);
AffineTransform rotation = new AffineTransform();
rotation.translate(drawAt.x, drawAt.y);
if (this.isStatic()) {
rotation.rotate(drawAt.getAngle(), -initialTranslation.x, -initialTranslation.y);
}
canvas.drawImage(rendered, rotation, null);
}
public void setTitle(String title) {
gauge.setTitle(title);
}
@Override
public void setInformation(Double information) {
gauge.setValue(information / this.scale);
}
}
\ No newline at end of file
......@@ -4,8 +4,8 @@
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of
* the License.
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
......@@ -49,20 +49,22 @@ public class Shadow extends Corona {
/** {@inheritDoc} */
@Override
public void paint(Graphics2D canvas) {
if (!active)
if (!active) {
return;
}
centre.toScreenCoordinates();
if (initialTranslation != null)
if (initialTranslation != null) {
initialTranslation.toScreenCoordinates();
}
Point drawAt = centre.add(initialTranslation);
AffineTransform transformation = new AffineTransform();
transformation.translate(drawAt.getX(), drawAt.getY());
if (rotateWithHandle)
if (rotateWithHandle) {
transformation.rotate(drawAt.getAngle());
}
canvas.setPaint(Color.gray);
canvas.fill(transformation.createTransformedShape(shape));
}
......
......@@ -220,6 +220,8 @@ public abstract class CoronaBuilder<B extends CoronaBuilder<B>> {
*
* @return An instance of the underlying {@link Corona} instance as defined by the concrete
* builder class.
* @throws BuildException
* Thrown when the {@link Corona} could not be built due to an internal error.
*/
public abstract Corona build();
public abstract Corona build() throws BuildException;
}
\ No newline at end of file
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.widget.corona.builder;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.corona.Gauge;
import java.util.List;
import eu.hansolo.steelseries.tools.Section;
/**
* @author nmack
* @date 28 Apr 2015
*
* <br>
* $Log: GaugeBuilder.java,v $
*/
public class GaugeBuilder extends CoronaBuilder<GaugeBuilder> {
public double width;
public double height;
public double lowerBound;
public double upperBound;
public double scale;
public String title;
public String unit;
public List<Section> sections;
public GaugeBuilder(Point centre) {
super(centre);
// TODO Auto-generated constructor stub
}
@Override
public Gauge build() throws BuildException {
// TODO Auto-generated method stub
return new Gauge(this);
}
/**
* Method used to set the dimensions of the gauge
*
* @param width
* The width of the gauge
* @param upperBound
* The height of the gauge
* @return An instance of the builder for chain-calling.
*/
public GaugeBuilder withDimensions(double width, double height) {
this.width = width;
this.height = height;
return this;
}
/**
* Method used to set the upper and lower bound of the dial
*
* @param lowerBound
* The lower bound of the dial
* @param upperBound
* The upper bound of the dial
* @return An instance of the builder for chain-calling.
*/
public GaugeBuilder withBounds(double lowerBound, double upperBound) {
this.lowerBound = lowerBound;
this.upperBound = upperBound;
return this;
}
/**
* Method used to set the upper and lower bound of the dial
*
* @param lowerBound
* The lower bound of the dial
* @param upperBound
* The upper bound of the dial
* @return An instance of the builder for chain-calling.
*/
public GaugeBuilder withScale(double scale) {
this.scale = scale;
return this;
}
public GaugeBuilder withTitle(String title) {
this.title = title;
return this;
}
public GaugeBuilder withUnit(String unit) {
this.unit = unit;
return this;
}
public GaugeBuilder withSections(List<Section> sections) {
this.sections = sections;
return this;
}
}
\ No newline at end of file
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