This repository has been archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Holger Reichert <mail@h0lger.de>
- Loading branch information
1 parent
19561ef
commit 4dd53d9
Showing
13 changed files
with
633 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
...rc/main/java/org/eclipse/smarthome/ui/internal/chart/defaultchartprovider/ChartTheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/** | ||
* Copyright (c) 2014-2017 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.ui.internal.chart.defaultchartprovider; | ||
|
||
import java.awt.Color; | ||
import java.awt.Font; | ||
|
||
/** | ||
* Chart styling theme for the {@link DefaultChartProvider}. | ||
* | ||
* @author Holger Reichert - Initial contribution | ||
* | ||
*/ | ||
public interface ChartTheme { | ||
|
||
/** | ||
* Theme name. Has to be unique across all themes. | ||
* | ||
* @return theme name | ||
*/ | ||
public String getThemeName(); | ||
|
||
/** | ||
* Background color, plot area. | ||
* | ||
* @return background color, plot area | ||
*/ | ||
public Color getPlotBackgroundColor(); | ||
|
||
/** | ||
* Color for the grid lines. | ||
* | ||
* @return color for the grid lines | ||
*/ | ||
public Color getPlotGridLinesColor(); | ||
|
||
/** | ||
* Return the width of the grid lines. | ||
* | ||
* @param dpi DPI dots per inch to calculate the width | ||
* @return width of the grid lines | ||
*/ | ||
public double getPlotGridLinesWidth(int dpi); | ||
|
||
/** | ||
* Return the dash spacing for the grid lines. | ||
* | ||
* @param dpi DPI dots per inch to calculate the width | ||
* @return dash spacing for the grid lines | ||
*/ | ||
public double getPlotGridLinesDash(int dpi); | ||
|
||
/** | ||
* Background color, legend area. | ||
* | ||
* @return background color, legend area | ||
*/ | ||
public Color getLegendBackgroundColor(); | ||
|
||
/** | ||
* Background color, whole chart | ||
* | ||
* @return background color, whole chart | ||
*/ | ||
public Color getChartBackgroundColor(); | ||
|
||
/** | ||
* Font color, legend and general use. | ||
* | ||
* @return | ||
*/ | ||
public Color getChartFontColor(); | ||
|
||
/** | ||
* Return a color for the given series number. | ||
* | ||
* @param series series number | ||
* @return color for the given series numer | ||
*/ | ||
public Color getLineColor(int series); | ||
|
||
/** | ||
* Return the width of the series lines. | ||
* | ||
* @param dpi DPI dots per inch to calculate the width | ||
* @return width of the series lines | ||
*/ | ||
public double getLineWidth(int dpi); | ||
|
||
/** | ||
* Color for the axis labels. | ||
* | ||
* @return | ||
*/ | ||
public Color getAxisTickLabelsColor(); | ||
|
||
/** | ||
* Font for the axis labels. | ||
* The font size gets calculated with the dpi parameter. | ||
* | ||
* @param dpi the DPI to calculate the font size | ||
* @return {@link Font} for the axis labels. | ||
*/ | ||
public Font getAxisTickLabelsFont(int dpi); | ||
|
||
/** | ||
* Font for the legend text. | ||
* The font size gets calculated with the dpi parameter. | ||
* | ||
* @param dpi the DPI to calculate the font size | ||
* @return {@link Font} for the legend text | ||
*/ | ||
public Font getLegendFont(int dpi); | ||
|
||
/** | ||
* Padding of the chart. | ||
* | ||
* @return padding of the chart | ||
*/ | ||
public int getChartPadding(); | ||
|
||
/** | ||
* Length of the line markers in the legend, in px. | ||
* | ||
* @return length of the line markers in the legend, in px | ||
*/ | ||
public int getLegendSeriesLineLength(); | ||
|
||
} |
114 changes: 114 additions & 0 deletions
114
...in/java/org/eclipse/smarthome/ui/internal/chart/defaultchartprovider/ChartThemeBlack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/** | ||
* Copyright (c) 2014-2017 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.ui.internal.chart.defaultchartprovider; | ||
|
||
import java.awt.Color; | ||
import java.awt.Font; | ||
|
||
/** | ||
* Implementation of the black {@link ChartTheme chart theme}. | ||
* | ||
* @author Holger Reichert - Initial contribution | ||
* | ||
*/ | ||
public class ChartThemeBlack implements ChartTheme { | ||
|
||
private static final String THEME_NAME = "black"; | ||
|
||
private Color[] LINECOLORS = new Color[] { // | ||
new Color(244, 67, 54), // red | ||
new Color(76, 175, 80), // green | ||
new Color(63, 81, 181), // blue | ||
new Color(156, 39, 176), // magenta/purple | ||
new Color(255, 152, 0), // orange | ||
new Color(0, 188, 212), // cyan | ||
new Color(233, 30, 99), // pink | ||
Color.WHITE, // white | ||
new Color(255, 235, 59) // yellow | ||
}; | ||
|
||
private static final String FONT_NAME = "SansSerif"; | ||
|
||
@Override | ||
public String getThemeName() { | ||
return THEME_NAME; | ||
} | ||
|
||
@Override | ||
public Color getPlotBackgroundColor() { | ||
return new Color(15, 15, 26); | ||
} | ||
|
||
@Override | ||
public Color getPlotGridLinesColor() { | ||
return Color.WHITE.darker(); | ||
} | ||
|
||
@Override | ||
public double getPlotGridLinesWidth(int dpi) { | ||
return Math.max(1.0, dpi / 64.0); | ||
} | ||
|
||
@Override | ||
public double getPlotGridLinesDash(int dpi) { | ||
return Math.max(3.0f, dpi / 32.0); | ||
} | ||
|
||
@Override | ||
public Color getLegendBackgroundColor() { | ||
return new Color(30, 30, 50, 160); | ||
} | ||
|
||
@Override | ||
public Color getChartBackgroundColor() { | ||
return new Color(0, 0, 0); | ||
} | ||
|
||
@Override | ||
public Color getChartFontColor() { | ||
return new Color(255, 255, 255, 255); | ||
} | ||
|
||
@Override | ||
public Color getLineColor(int series) { | ||
return LINECOLORS[series % LINECOLORS.length]; | ||
} | ||
|
||
@Override | ||
public double getLineWidth(int dpi) { | ||
return Math.max(1.0, dpi / 64.0); | ||
} | ||
|
||
@Override | ||
public Color getAxisTickLabelsColor() { | ||
return getChartFontColor(); | ||
} | ||
|
||
@Override | ||
public Font getAxisTickLabelsFont(int dpi) { | ||
int fontsize = (int) Math.max(8, Math.round(dpi / 8.5)); | ||
return new Font(FONT_NAME, Font.PLAIN, fontsize); | ||
} | ||
|
||
@Override | ||
public Font getLegendFont(int dpi) { | ||
int fontsize = (int) Math.max(8, Math.round(dpi / 9.6)); | ||
return new Font(FONT_NAME, Font.PLAIN, fontsize); | ||
} | ||
|
||
@Override | ||
public int getChartPadding() { | ||
return 5; | ||
} | ||
|
||
@Override | ||
public int getLegendSeriesLineLength() { | ||
return 10; | ||
} | ||
|
||
} |
Oops, something went wrong.