Skip to content
Snippets Groups Projects
Commit d4c0c8f5 authored by Johannes Eder's avatar Johannes Eder
Browse files

Merge remote-tracking branch 'origin/master' into 4018_ErrorViewJavaFX

parents c7834450 f4429a9d
No related branches found
No related tags found
1 merge request!1244018 error view java fx
Showing
with 379 additions and 454 deletions
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.control;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.common.ui.javafx.style.LineStyle;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.ChartStyle;
import org.fortiss.tooling.spiderchart.style.LegendStyle;
import javafx.geometry.Dimension2D;
import javafx.scene.canvas.GraphicsContext;
/**
* Class used for drawing the the spider chart legend.
*
* @author hoelzl
*/
public final class SpiderChartLegendControl extends SpiderChartControlBase {
/** The length of the line for each data series. */
private static final double LINE_SIZE = 20;
/** The space between line and text. */
private static final double LINE_SPACE = 5;
/** Constructor. */
public SpiderChartLegendControl(SpiderChart chart, ChartStyle style) {
super(chart, style);
}
/** Draws the provided graphics */
public void draw(GraphicsContext gc) {
if(!style.isShowLegend()) {
return;
}
if(style.getLegendStyle().isVerticalLayout()) {
drawVertical(gc);
} else {
drawHorizontal(gc);
}
}
/** Draws the graphics horizontally. */
public void drawHorizontal(GraphicsContext gc) {
String labelText = chart.getLegendLabel();
double margin = style.getLegendStyle().getMargin();
double xDelta = 0;
if(labelText != null && labelText.trim().length() > 0) {
xDelta = drawHorizontalLabel(gc);
}
double y = getY() + margin;
for(DataSeries data : chart.getDataSeries()) {
String text = data.getName();
FontStyle fontStyle = style.getDataSeriesStyle(data).getIndicatorLabelStyle();
Dimension2D extent = fontStyle.getTextBounds(text);
LineStyle l = style.getDataSeriesStyle(data).getLineStyle();
double xl = getX() + xDelta;
l.drawLine(gc, xl, y - extent.getHeight() / 4, xl + LINE_SIZE,
y - extent.getHeight() / 4);
xDelta = xDelta + LINE_SIZE + LINE_SPACE;
double xs = getX() + xDelta;
fontStyle.drawText(gc, text, xs, y);
xDelta = xDelta + extent.getWidth() + margin;
}
}
/** Draws the horizontal legend label and returns the offset. */
private double drawHorizontalLabel(GraphicsContext gc) {
String labelText = chart.getLegendLabel();
LegendStyle legendStyle = style.getLegendStyle();
FontStyle labelStyle = legendStyle.getLabelStyle();
double margin = legendStyle.getMargin();
double textExtent = labelStyle.getTextBounds(labelText).getWidth();
labelStyle.drawText(gc, labelText, getX() + margin, getY() + margin);
return textExtent + 2 * margin;
}
/** Draws the graphics vertically. */
public void drawVertical(GraphicsContext gc) {
String labelText = chart.getLegendLabel();
LegendStyle legendStyle = style.getLegendStyle();
double margin = legendStyle.getMargin();
double yDelta = 0;
if(labelText != null && labelText.trim().length() > 0) {
yDelta = drawVerticalLabel(gc);
}
double textWidth = 0;
double textHeight = 0;
for(DataSeries data : chart.getDataSeries()) {
Dimension2D extent = legendStyle.getLabelStyle().getTextBounds(data.getName());
textWidth = Math.max(textWidth, extent.getWidth());
textHeight = Math.max(textHeight, extent.getHeight());
}
int cnt = 0;
for(DataSeries data : chart.getDataSeries()) {
double dY = yDelta + cnt * (textHeight + margin);
double dX = LINE_SIZE + 2 * margin;
LineStyle l = style.getDataSeriesStyle(data).getLineStyle();
double lY = dY + textHeight / 2;
l.drawLine(gc, getX() + margin, getY() + lY, getX() + margin + LINE_SIZE, getY() + lY);
style.getDataSeriesStyle(data).getIndicatorLabelStyle().drawText(gc, data.getName(),
getX() + dX, getY() + dY);
cnt++;
}
}
/** Draws the header label for the vertical legend layout and returns the offset. */
private double drawVerticalLabel(GraphicsContext gc) {
String labelText = chart.getLegendLabel();
LegendStyle legendStyle = style.getLegendStyle();
FontStyle labelStyle = legendStyle.getLabelStyle();
double margin = legendStyle.getMargin();
Dimension2D textExtent = labelStyle.getTextBounds(labelText);
double x = getX() + margin + (getWidth() - margin - textExtent.getWidth()) / 2;
labelStyle.drawText(gc, labelText, x, getY() + margin);
return textExtent.getHeight() + margin;
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.control;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.ChartStyle;
import javafx.geometry.Dimension2D;
import javafx.scene.canvas.GraphicsContext;
/**
* Class used for drawing the spider chart title.
*
* @author hoelzl
*/
public final class SpiderChartTitleControl extends SpiderChartControlBase {
/** Constructor */
public SpiderChartTitleControl(SpiderChart chart, ChartStyle style) {
super(chart, style);
}
/** Used to draw the title */
public void draw(GraphicsContext gc) {
if(!style.isShowTitle()) {
return;
}
String text = chart.getTitle();
if(text == null || text.trim().length() == 0) {
return;
}
gc.save();
FontStyle fontStyle = style.getTitleStyle();
Dimension2D extent = fontStyle.getTextBounds(text);
double x = getX() + getWidth() / 2 - extent.getWidth() / 2;
double y = getY() + getHeight() / 2 - extent.getHeight() / 2;
fontStyle.drawText(gc, text, x, y);
gc.restore();
}
}
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.control;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
import org.fortiss.tooling.spiderchart.style.ChartStyle;
import javafx.geometry.Bounds;
import javafx.scene.canvas.Canvas;
import javafx.scene.layout.Pane;
/**
* Represents a viewer on the canvas to display the spider chart.
*
* @author hoelzl
*/
public final class SpiderChartViewer {
/** The viewer main pane. */
private final Pane viewerPane;
/** The actual canvas to be used for drawing. */
private final SpiderChartCanvas canvas;
/** Constructor */
public SpiderChartViewer(SpiderChart chart, ChartStyle style) {
canvas = new SpiderChartCanvas(chart, style);
viewerPane = new Pane();
viewerPane.getChildren().add(canvas.getCanvasControl());
viewerPane.widthProperty().addListener(evt -> {
updateCanvasSize();
});
viewerPane.heightProperty().addListener(evt -> {
updateCanvasSize();
});
}
/** Updates the canvas size after viewer size changed. */
protected void updateCanvasSize() {
Bounds b = viewerPane.getLayoutBounds();
Canvas c = canvas.getCanvasControl();
c.setWidth(b.getWidth());
c.setHeight(b.getHeight());
}
/** Returns the viewer pane. */
public Pane getViewerPane() {
return viewerPane;
}
}
AxisBase.java 59936f17099d2262635e872efa232d717d6ca4d4 GREEN
DataSeries.java 85831f58bec44db8b42d00b86b74c3a572b65bd8 GREEN
DoubleAxis.java fe58c07ebc364d939346048173bcbd493dbac347 GREEN
EnumerationAxis.java 0ec318d6394c20d4dc779bb9736a96d3f8f04263 GREEN
SpiderChart.java 5a61c43903b9f6cc3ebc07ed2c14f1f1ef60da08 GREEN
AxisBase.java 201e1e5fbd8d672ddf05e3bccf464eafe0850991 GREEN
DataSeries.java ca210729107a39adf3e27fffb620694ebe2e0ee1 GREEN
DoubleAxis.java 4fc73d9fb1d19fbb4f2e68e417af0376dce61c23 GREEN
EnumerationAxis.java b61bcfdaed2e3d4cc2172d9289496f711e92723c GREEN
SpiderChart.java 84df851b06832707a40f66dfde4b43f523ee5ea5 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.model;
import static java.util.Objects.requireNonNull;
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.model;
import static java.util.Objects.requireNonNull;
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.model;
import java.util.Comparator;
/**
* Class representing an axis of the spider chart.
* Class representing an axis of the spider chart displaying double values.
*
* @author hoelzl
*/
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.model;
import static java.util.Collections.sort;
......@@ -21,7 +15,7 @@ import java.util.Comparator;
import java.util.List;
/**
* An axis that represents an enumeration.
* Class representing an axis of the spider chart that displays enumeration values.
*
* @author hoelzl
*/
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.model;
import static org.conqat.lib.commons.collections.CollectionUtils.asUnmodifiable;
import static java.util.Collections.unmodifiableList;
import java.util.ArrayList;
import java.util.List;
......@@ -75,12 +69,12 @@ public final class SpiderChart {
/** Returns the unmodifiable list of axes. */
public List<AxisBase> getAxes() {
return asUnmodifiable(axes);
return unmodifiableList(axes);
}
/** Returns the unmodifiable list of data series. */
public List<DataSeries> getDataSeries() {
return asUnmodifiable(dataSeries);
return unmodifiableList(dataSeries);
}
/** Returns the legend label. */
......
AxisStyle.java 7c106a32ed09f4674131c486956f84839bd5467c GREEN
ChartStyle.java b2c76a10141ebe9a083d5456bd9e5ef61f472500 GREEN
ColorStyleBase.java b8e824b55490b30507b8d38acf10bc61daf1fa00 GREEN
DataSeriesStyle.java a7bda5ba4e12133ea20edda627e41560b3679641 GREEN
FillStyle.java 36e54f1ecb31836a7c7a821ddf0432264349bd83 GREEN
FontStyle.java 012dfcddfd85159ba6045141df0762289fb70d6f GREEN
LegendStyle.java 39a10d789aeac41114b8b43e7e6790543cb2f618 GREEN
LineStyle.java bc3df608b46c9d2fa367cf75465961389ab4491f GREEN
AxisStyle.java 9e4fc8ad4e2fcaf4d7af87bc3b9d3422a7589dc8 GREEN
ChartStyle.java 308c56bcb1c7c4c1a1f76c02cc3f8d361ea06f7e GREEN
DataSeriesStyle.java 5c9ecf7e9b3f89759cefe309ab5e86fb5c246760 GREEN
LegendStyle.java b4dd4125b87d412a607e311593503206326d9b0a GREEN
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.style;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_12PT;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_8PT;
import static org.fortiss.tooling.spiderchart.style.LineStyle.SOLID_BLACK_1PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_12PT;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_8PT;
import static org.fortiss.tooling.common.ui.javafx.style.LineStyle.SOLID_BLACK_1PT;
import java.text.DecimalFormat;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.common.ui.javafx.style.LineStyle;
import org.fortiss.tooling.spiderchart.model.DoubleAxis;
/**
* Class for all style attributes for {@link DoubleAxis spider chart axes}.
* Class for all style attributes of {@link DoubleAxis spider chart axes}.
* <P>
* If {@link #segmentStyle} is non-null then indicators will be drawn.
*
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.style;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.GREEN;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.getBrighterColor;
import static javafx.scene.paint.Color.GREEN;
import java.util.HashMap;
import java.util.Map;
import org.fortiss.tooling.common.ui.javafx.style.FillStyle;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.common.ui.javafx.style.LineStyle;
import org.fortiss.tooling.spiderchart.model.AxisBase;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.SpiderChart;
......@@ -29,6 +25,7 @@ import org.fortiss.tooling.spiderchart.model.SpiderChart;
* Class for all style attributes of the {@link SpiderChart spider chart}.
*
* @author hoelzl
* @author munaro
*/
public final class ChartStyle {
/** The map for style information of axes. */
......@@ -62,7 +59,7 @@ public final class ChartStyle {
* The {@link FillStyle} used for the background if {@link #useIndividualAxisSegments} is
* <code>false</code>.
*/
private FillStyle backgroundFillStyle = new FillStyle(getBrighterColor(GREEN));
private FillStyle backgroundFillStyle = new FillStyle(GREEN.brighter());
/**
* The {@link LineStyle} used for the background if {@link #useIndividualAxisSegments} is false.
*/
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.style;
import static org.fortiss.tooling.spiderchart.style.FontStyle.BLACK_VERDANA_10PT;
import static org.fortiss.tooling.spiderchart.style.LineStyle.SOLID_BLACK_1PT;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.LIGHT_GRAY;
import static javafx.scene.paint.Color.LIGHTGRAY;
import static org.fortiss.tooling.common.ui.javafx.style.FontStyle.BLACK_VERDANA_10PT;
import static org.fortiss.tooling.common.ui.javafx.style.LineStyle.SOLID_BLACK_1PT;
import java.text.DecimalFormat;
import org.fortiss.tooling.common.ui.javafx.style.FillStyle;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
import org.fortiss.tooling.common.ui.javafx.style.LineStyle;
import org.fortiss.tooling.spiderchart.model.AxisBase;
import org.fortiss.tooling.spiderchart.model.DataSeries;
import org.fortiss.tooling.spiderchart.model.DoubleAxis;
......@@ -39,7 +36,7 @@ public final class DataSeriesStyle {
/** The font style of the data series indicators. */
private final FontStyle indicatorLabelStyle;
/** The size of the indicator box. Default is 7. */
private final int indicatorSize;
private final double indicatorSize;
/** The flag to show indicator boxes. */
private final boolean showIndicators;
/** The flag to show indicator labels. */
......@@ -49,7 +46,7 @@ public final class DataSeriesStyle {
/** Constructor. */
public DataSeriesStyle(LineStyle lineStyle, FillStyle fillStyle, boolean withIndicators,
boolean withIndicatorLabels, FontStyle indicatorStyle, int indicatorSize,
boolean withIndicatorLabels, FontStyle indicatorStyle, double indicatorSize,
DecimalFormat decimalFormat) {
this.lineStyle = lineStyle;
this.fillStyle = fillStyle;
......@@ -62,7 +59,7 @@ public final class DataSeriesStyle {
/** Constructor. */
public DataSeriesStyle() {
this(SOLID_BLACK_1PT, new FillStyle(LIGHT_GRAY), true, true, BLACK_VERDANA_10PT, 7,
this(SOLID_BLACK_1PT, new FillStyle(LIGHTGRAY), true, true, BLACK_VERDANA_10PT, 7,
new DecimalFormat("#.##"));
}
......@@ -92,7 +89,7 @@ public final class DataSeriesStyle {
}
/** Returns the size of the indicator box. */
public int getIndicatorSize() {
public double getIndicatorSize() {
return indicatorSize;
}
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.style;
import org.eclipse.swt.graphics.RGB;
/**
* Represents a style to be used in for filling areas.
*
* @author mondal
* @author hoelzl
*/
public final class FillStyle extends ColorStyleBase {
/** Alpha transparency value (default is opaque 255). */
private final int alpha;
/** Constructor */
public FillStyle(RGB rgbColor) {
this(rgbColor, 255);
}
/** Constructor */
public FillStyle(RGB rgbColor, int alpha) {
super(rgbColor);
this.alpha = alpha;
}
/** Returns alpha value. */
public int getAlpha() {
return alpha;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.style;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_10PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_12PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_14PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_16PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_18PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_8PT;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.BLACK;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
/**
* Class for style attributes of fonts (FontData and SWT color).
*
* @author hoelzl
*/
public final class FontStyle extends ColorStyleBase {
/** Black Verdana 18 point. */
public static final FontStyle BLACK_VERDANA_18PT = new FontStyle(VERDANA_18PT, BLACK);
/** Black Verdana 16 point. */
public static final FontStyle BLACK_VERDANA_16PT = new FontStyle(VERDANA_16PT, BLACK);
/** Black Verdana 14 point. */
public static final FontStyle BLACK_VERDANA_14PT = new FontStyle(VERDANA_14PT, BLACK);
/** Black Verdana 12 point. */
public static final FontStyle BLACK_VERDANA_12PT = new FontStyle(VERDANA_12PT, BLACK);
/** Black Verdana 10 point. */
public static final FontStyle BLACK_VERDANA_10PT = new FontStyle(VERDANA_10PT, BLACK);
/** Black Verdana 8 point. */
public static final FontStyle BLACK_VERDANA_8PT = new FontStyle(VERDANA_8PT, BLACK);
/** The font data. */
private final FontData fontData;
/** Constructor. */
public FontStyle(FontData fontData, RGB rgbColor) {
super(rgbColor);
this.fontData = fontData;
}
/** Returns font data. */
public final FontData getFontData() {
return fontData;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.style;
import org.eclipse.swt.graphics.RGB;
import org.fortiss.tooling.common.ui.javafx.style.FontStyle;
/**
* Class for all style attributes of the spider chart legend.
*
* @author hoelzl
*/
public final class LegendStyle extends ColorStyleBase {
public final class LegendStyle {
/** The vertical / horizontal layout flag. */
private boolean verticalLayout;
/** The inner margins. */
private int margin = 5;
private double margin = 5;
/** The font style of the label. */
private FontStyle labelStyle;
/** Constructor. */
public LegendStyle(RGB rgbColor, boolean verticalLayout, int margin, FontStyle labelStyle) {
super(rgbColor);
public LegendStyle(boolean verticalLayout, double margin, FontStyle labelStyle) {
this.margin = Math.max(5, margin);
this.verticalLayout = verticalLayout;
this.labelStyle = labelStyle;
......@@ -44,7 +37,7 @@ public final class LegendStyle extends ColorStyleBase {
}
/** Returns margin. */
public int getMargin() {
public double getMargin() {
return margin;
}
......
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.style;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.BLACK;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.fortiss.tooling.base.ui.utils.GCStateManager;
/**
* Represents a style to be used in SWT spider chart graphics.
*
* @author mondal
*/
public final class LineStyle extends ColorStyleBase {
/** Solid, black line with width of one point. */
public static final LineStyle SOLID_BLACK_1PT = new LineStyle(BLACK, 1, SWT.LINE_SOLID);
/** The type of the line. */
private final int swtLineStyle;
/** The width of the line. */
private final int width;
/** Constructor */
public LineStyle(RGB rgbColor, int width, int swtLineStyle) {
super(rgbColor);
this.width = width;
this.swtLineStyle = swtLineStyle;
}
/** Constructor */
public LineStyle(RGB rgbColor) {
this(rgbColor, 1, SWT.LINE_SOLID);
}
/** Draws the line */
public void draw(GCStateManager gcState, int x1, int y1, int x2, int y2) {
gcState.foregroundStoreAndCreate(getRGBColor());
gcState.lineStoreAndSet(width, swtLineStyle);
gcState.GC().drawLine(x1, y1, x2, y2);
gcState.lineRestore().foregroundRestoreAndDispose();
}
}
AxisUtils.java 6fc6928adad9955184284f56919193218d24f087 GREEN
RGBColorUtils.java 2fc319ab0bc3d898f7c68db324cded3ddcd45f70 GREEN
AxisUtils.java 728130b4956452cd0e0258489e4eda1cc1b9e259 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
/*******************************************************************************
* Copyright (c) 2017, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0, which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.spiderchart.util;
import org.eclipse.swt.graphics.Point;
import org.fortiss.tooling.spiderchart.model.DoubleAxis;
import org.fortiss.tooling.spiderchart.style.AxisStyle;
import javafx.geometry.Point2D;
/**
* Utility methods related to {@link DoubleAxis} and {@link AxisStyle}.
*
* @author hoelzl
* @author munaro
*/
public class AxisUtils {
/** Returns the segment point on the axis if the the axis displayed with the given extents. */
public static Point getSegmentPoint(int numberOfSegments, int segment, int extentX,
int extentY) {
int segmentX = extentX / numberOfSegments;
int segmentY = extentY / numberOfSegments;
return new Point(segmentX * segment, segmentY * segment);
public static Point2D getSegmentPoint(int numberOfSegments, int segment, double extentX,
double extentY) {
double segmentX = extentX / numberOfSegments;
double segmentY = extentY / numberOfSegments;
return new Point2D(segmentX * segment, segmentY * segment);
}
/** Returns the segment point on the axis if the the axis displayed with the given extents. */
public static Point getSegmentPoint(AxisStyle style, int segment, Point extent) {
return getSegmentPoint(style.getSegments(), segment, extent.x, extent.y);
public static Point2D getSegmentPoint(AxisStyle style, int segment, Point2D extent) {
return getSegmentPoint(style.getSegments(), segment, extent.getX(), extent.getY());
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.util;
import static java.lang.Math.max;
import static java.lang.Math.min;
import org.eclipse.swt.graphics.RGB;
/**
* Utility class for handling colors with a set of commonly used colors.
*
* @author mondal
* @author hoelzl
*/
public final class RGBColorUtils {
/** The RGB color black. */
public static final RGB BLACK = new RGB(0, 0, 0);
/** The RGB color white. */
public static final RGB WHITE = new RGB(255, 255, 255);
/** The RGB color red. */
public static final RGB RED = new RGB(255, 0, 0);
/** The RGB color green. */
public static final RGB GREEN = new RGB(0, 255, 0);
/** The RGB color blue. */
public static final RGB BLUE = new RGB(0, 0, 255);
/** The RGB color cyan. */
public static final RGB CYAN = new RGB(0, 255, 255);
/** The RGB color magenta. */
public static final RGB MAGENTA = new RGB(255, 0, 128);
/** The RGB color yellow. */
public static final RGB YELLOW = new RGB(255, 255, 255);
/** The RGB color light gray. */
public static final RGB LIGHT_GRAY = new RGB(192, 192, 192);
/** The RGB color gray. */
public static final RGB GRAY = new RGB(128, 128, 128);
/** The RGB color dark gry. */
public static final RGB DARK_GRAY = new RGB(70, 70, 70);
/** The RGB color pink. */
public static final RGB PINK = new RGB(255, 255, 255);
/** The RGB color lime. */
public static final RGB LIME = convert(65280);
/** The RGB color olive. */
public static final RGB OLIVE = convert(8421376);
/** The RGB color navy. */
public static final RGB NAVY = new RGB(0, 0, 128);
/** Returns the color, which is 10% brighter than the given color. */
public static RGB getBrighterColor(RGB color) {
int percent = 10;
int rr = color.red;
int gg = color.green;
int bb = color.blue;
int r = rr + percent * (rr / 100);
int g = gg + percent * (gg / 100);
int b = bb + percent * (bb / 100);
return new RGB(min(r, 255), min(g, 255), min(b, 255));
}
/** Returns the color, which is 10% darker than the given color. */
public static RGB getDarkerColor(RGB color) {
int percent = 10;
int rr = color.red;
int gg = color.green;
int bb = color.blue;
int r = rr - percent * (rr / 100);
int g = gg - percent * (gg / 100);
int b = bb - percent * (bb / 100);
return new RGB(max(r, 0), max(g, 0), max(b, 0));
}
/** Converts from integer value to RGB instance. */
private static RGB convert(int rgb) {
int red = rgb >> 16 & 0xFF;
int green = rgb >> 8 & 0xFF;
int blue = rgb & 0xFF;
return new RGB(red, green, blue);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment