case DAChartSeries.SERIES_STYLE_LAST_CONTINUE_STEP:
drawStepSeries(gc, series, false);
break;
+ case DAChartSeries.SERIES_STYLE_STATE_AREA:
+ drawStateAreaSeries(gc, series, i, seriesList.size());
+ break;
default:
DA_LOG.debug("Undefined series style");
break;
gc.setAlpha(255);
}
-
+
+ private void drawStateAreaSeries(GC gc, DAChartSeries series, int seriesIndex,
+ int seriesSize) {
+ List<DAChartSeriesItem> seriesItems = series.getSeriesItemList();
+ if (null == seriesItems) {
+ return;
+ }
+
+ int seriesItemSize = seriesItems.size();
+ if (seriesItemSize < 1) {
+ return;
+ }
+ int index = series.getPrevIndexByXvalue(plot.getVisibleStartX());
+ if (index < 0) {
+ index = 0;
+ }
+
+ final int MARGIN_PERCENT = 20; // It's mean 20%
+ final int STATE_AREA_BAR_WIDTH = 1;
+ final int DIAGONAL_DIVIDE = 16; // divided in 16 pieces for diagonal box size.
+ final Color DIAGONAL_BOX_COLOR = ColorResources.WHITE;
+ /*
+ * Formula to divide in equal series heights.
+ */
+ int margin = (int)((r.height * (MARGIN_PERCENT / 100.0)) / (seriesSize + 1));
+ int areaHeight = (r.height - margin * (seriesSize + 1)) / seriesSize;
+ int pixcelStartY = (margin * (seriesIndex + 1)) + (areaHeight * seriesIndex);
+
+ List<DAChartSeriesItem> barSeriesItems = new ArrayList<DAChartSeriesItem>();
+ /*
+ * 1. Draw Start/End Status Area.
+ */
+ for (int i = 0; i < seriesItemSize; i++) {
+ DAChartSeriesItem seriesItem = seriesItems.get(i);
+ DAChartSeriesItem endSeriesItem = null;
+
+ int type = (int) seriesItem.getY();
+ if (DAChartSeriesItem.SERIES_AREA_START == type) {
+ int startCount = 1;
+ /*
+ * Find end series item matched with start series item.
+ */
+ for (int ii = i + 1; ii < seriesItemSize; ii++) {
+ DAChartSeriesItem nextSeriesItem = seriesItems.get(ii);
+ int nextType = (int) nextSeriesItem.getY();
+ if (nextType == DAChartSeriesItem.SERIES_AREA_START) {
+ startCount += 1;
+ } else if (nextType == DAChartSeriesItem.SERIES_AREA_END) {
+ --startCount;
+ if (startCount == 0) {
+ endSeriesItem = nextSeriesItem;
+ break;
+ }
+ }
+ }
+ Color foreGroundColor = seriesItem.getGradationForegroundColor();
+ Color backGroundcolor = seriesItem.getColor();
+ gc.setForeground(foreGroundColor);
+ gc.setBackground(backGroundcolor);
+
+ int pixcelStartX = plot.getXPixcelFromX(seriesItem.getX(), r);
+ int pixcelWidth;
+ if (endSeriesItem != null) {
+ pixcelWidth = plot.getXPixcelFromX(endSeriesItem.getX(), r) - pixcelStartX;
+ } else {
+ /*
+ * endSeriesItem is null when end series is not exist. this case, draw it as much as visibleEndX.
+ */
+ pixcelWidth = plot.getXPixcelFromX(plot.getVisibleEndX(), r) - pixcelStartX;
+ }
+ gc.fillRectangle(pixcelStartX, pixcelStartY, pixcelWidth, areaHeight);
+
+ /*
+ * If it's needed, draw diagonal line. diagonal line is composed of square boxes.
+ * Direction of diagonal line is right top to left down like "/".
+ */
+ if (seriesItem.getDiagonal()) {
+ int diagonalBoxSize = areaHeight / DIAGONAL_DIVIDE;
+ gc.setForeground(DIAGONAL_BOX_COLOR);
+ gc.setBackground(DIAGONAL_BOX_COLOR);
+ for (int j = 0; j < 16; j++) {
+ int boxY = pixcelStartY + (diagonalBoxSize * j);
+ // Formula to draw diagonal line like "/"
+ for (int k = 3 - (j % 4) - (j / 4); k < pixcelWidth; k = k + 3) {
+ int boxX = diagonalBoxSize * k + pixcelStartX;
+ if (pixcelStartX <= boxX && boxX <= pixcelWidth + pixcelStartX - diagonalBoxSize) {
+ gc.fillRectangle(boxX, boxY, diagonalBoxSize, diagonalBoxSize);
+ }
+ }
+ }
+ }
+ } else if (DAChartSeriesItem.SERIES_AREA_BAR == type) {
+ barSeriesItems.add(seriesItem);
+ }
+ }
+
+ /*
+ * 2. Draw Bar series
+ */
+ for (int i = 0; i < barSeriesItems.size(); i++) {
+ DAChartSeriesItem barSeriesItem = barSeriesItems.get(i);
+ Color foreGroundColor = barSeriesItem.getGradationForegroundColor();
+ Color backGroundcolor = barSeriesItem.getColor();
+ gc.setForeground(foreGroundColor);
+ gc.setBackground(backGroundcolor);
+ int pixcelStartX = plot.getXPixcelFromX(barSeriesItem.getX(), r);
+ gc.fillRectangle(pixcelStartX, pixcelStartY, STATE_AREA_BAR_WIDTH, areaHeight);
+ }
+ }
+
private void drawStepSeries(GC gc, DAChartSeries series, boolean bEndVal) {
List<DAChartSeriesItem> seriesItems = series.getSeriesItemList();
if (seriesItems == null) {
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jungwook Ryu <jungwook.ryu@samsung.com>
* yeongtaik byeon <yeongtaik.byeon@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
*
public static final int SERIES_ARROW_NONE = 0;
public static final int SERIES_ARROW_LEFT = -1;
public static final int SERIES_ARROW_RIGHT = 1;
+ public static final int SERIES_AREA_START = 0;
+ public static final int SERIES_AREA_END = 1;
+ public static final int SERIES_AREA_BAR = 2;
protected double x = 0;
private double y = 0;
private double barWidth = -1;
private Image image = null;
private String tooltipText;
private boolean showTimeInfo = true;
+ private boolean diagonal = false;
public DAChartSeriesItem(double x, double y) {
this.x = x;
this.color = gradationBackgroundColor;
this.tooltipText = tooltipText;
}
+
+ public DAChartSeriesItem(double x, double y,
+ Color gradationForegroundColor,
+ Color gradationBackgroundColor,
+ boolean diagonal,
+ String tooltipText) {
+ this(x, y, gradationForegroundColor,
+ gradationBackgroundColor, tooltipText);
+ this.diagonal = diagonal;
+ }
public DAChartSeriesItem(double x, double y, Image image) {
this.x = x;
Color gradationForegroundColor) {
this.gradationForegroundColor = gradationForegroundColor;
}
+
+ public boolean getDiagonal() {
+ return this.diagonal;
+ }
}