-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #367 - Custom Series - add support for rectangle and line
- Loading branch information
1 parent
7eb8c43
commit ffe34bb
Showing
9 changed files
with
256 additions
and
88 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...clipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/model/AbstractElement.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,100 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Lablicate GmbH. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Philip Wenig - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swtchart.extensions.model; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.graphics.Color; | ||
import org.eclipse.swt.widgets.Display; | ||
|
||
public abstract class AbstractElement implements IElement { | ||
|
||
private double x = 0.0d; | ||
private double y = 0.0d; | ||
private Color color = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); | ||
private int alpha = 255; | ||
|
||
@Override | ||
public double getX() { | ||
|
||
return x; | ||
} | ||
|
||
@Override | ||
public void setX(double x) { | ||
|
||
this.x = x; | ||
} | ||
|
||
@Override | ||
public double getY() { | ||
|
||
return y; | ||
} | ||
|
||
@Override | ||
public void setY(double y) { | ||
|
||
this.y = y; | ||
} | ||
|
||
@Override | ||
public Color getColor() { | ||
|
||
return color; | ||
} | ||
|
||
@Override | ||
public void setColor(Color color) { | ||
|
||
this.color = color; | ||
} | ||
|
||
@Override | ||
public int getAlpha() { | ||
|
||
return alpha; | ||
} | ||
|
||
@Override | ||
public void setAlpha(int alpha) { | ||
|
||
this.alpha = alpha; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
|
||
return Objects.hash(color, x, y); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
|
||
if(this == obj) | ||
return true; | ||
if(obj == null) | ||
return false; | ||
if(getClass() != obj.getClass()) | ||
return false; | ||
AbstractElement other = (AbstractElement)obj; | ||
return Objects.equals(color, other.color) && Double.doubleToLongBits(x) == Double.doubleToLongBits(other.x) && Double.doubleToLongBits(y) == Double.doubleToLongBits(other.y); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return "AbstractElement [x=" + x + ", y=" + y + ", color=" + color + "]"; | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/model/ElementLine.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,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Lablicate GmbH. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Philip Wenig - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swtchart.extensions.model; | ||
|
||
import org.eclipse.swtchart.LineStyle; | ||
|
||
public class ElementLine extends AbstractElement implements IGraphicElement { | ||
|
||
private double x2 = 0.0d; | ||
private double y2 = 0.0d; | ||
private LineStyle lineStyle = LineStyle.SOLID; | ||
private int lineWidth = 1; | ||
|
||
public double getX2() { | ||
|
||
return x2; | ||
} | ||
|
||
public void setX2(double x2) { | ||
|
||
this.x2 = x2; | ||
} | ||
|
||
public double getY2() { | ||
|
||
return y2; | ||
} | ||
|
||
public void setY2(double y2) { | ||
|
||
this.y2 = y2; | ||
} | ||
|
||
public LineStyle getLineStyle() { | ||
|
||
return lineStyle; | ||
} | ||
|
||
public void setLineStyle(LineStyle lineStyle) { | ||
|
||
this.lineStyle = lineStyle; | ||
} | ||
|
||
public int getLineWidth() { | ||
|
||
return lineWidth; | ||
} | ||
|
||
public void setLineWidth(int lineWidth) { | ||
|
||
this.lineWidth = lineWidth; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...lipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/model/ElementRectangle.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,39 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Lablicate GmbH. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Philip Wenig - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swtchart.extensions.model; | ||
|
||
public class ElementRectangle extends AbstractElement implements IGraphicElement { | ||
|
||
private double width = 0.0d; | ||
private double height = 0.0d; | ||
|
||
public double getWidth() { | ||
|
||
return width; | ||
} | ||
|
||
public void setWidth(double width) { | ||
|
||
this.width = width; | ||
} | ||
|
||
public double getHeight() { | ||
|
||
return height; | ||
} | ||
|
||
public void setHeight(double height) { | ||
|
||
this.height = height; | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/model/IElement.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,41 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Lablicate GmbH. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Philip Wenig - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swtchart.extensions.model; | ||
|
||
import org.eclipse.swt.graphics.Color; | ||
|
||
public interface IElement { | ||
|
||
double POSITION_TOP_Y = Double.NEGATIVE_INFINITY; | ||
double POSITION_BOTTOM_Y = Double.POSITIVE_INFINITY; | ||
double POSITION_LEFT_X = Double.NEGATIVE_INFINITY; | ||
double POSITION_RIGHT_X = Double.POSITIVE_INFINITY; | ||
double MAX_HEIGHT = Double.POSITIVE_INFINITY; | ||
double MAX_WIDTH = Double.POSITIVE_INFINITY; | ||
|
||
double getX(); | ||
|
||
void setX(double x); | ||
|
||
double getY(); | ||
|
||
void setY(double y); | ||
|
||
Color getColor(); | ||
|
||
void setColor(Color color); | ||
|
||
int getAlpha(); | ||
|
||
void setAlpha(int alpha); | ||
} |
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
Oops, something went wrong.