Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in cdk-1.4.x with the 1.4.3 changes
- Loading branch information
Showing
7 changed files
with
196 additions
and
1 deletion.
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
66 changes: 66 additions & 0 deletions
66
src/main/org/openscience/cdk/renderer/elements/ArrowElement.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,66 @@ | ||
/* Copyright (C) 2009 Stefan Kuhn <shk3@users.sf.net> | ||
* 2011 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* Contact: cdk-devel@list.sourceforge.net | ||
* | ||
* This program 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; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program 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 this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
package org.openscience.cdk.renderer.elements; | ||
|
||
import java.awt.Color; | ||
|
||
/** | ||
* {@link IRenderingElement} for linear arrows. | ||
* | ||
* @cdk.module renderbasic | ||
*/ | ||
public class ArrowElement implements IRenderingElement { | ||
|
||
public final double startX; | ||
public final double startY; | ||
public final double endX; | ||
public final double endY; | ||
public final double width; | ||
public final Color color; | ||
public final boolean direction; | ||
|
||
/** | ||
* Constructor for an arrow element, based on starting point, end point, width, | ||
* direction, and color. | ||
* | ||
* @param startX X coordinate of the point where the arrow starts. | ||
* @param startY Y coodrinate of the point where the arrow starts. | ||
* @param endX X coordinate of the point where the arrow ends. | ||
* @param endY Y coordinate of the point where the arrow ends. | ||
* @param width width of the arrow line. | ||
* @param direction true is the arrow points from start to end, false if from end to start | ||
* @param color {@link Color} of the arrow | ||
*/ | ||
public ArrowElement(double startX, double startY, double endX, double endY, | ||
double width, boolean direction, Color color) { | ||
this.endX = startX; | ||
this.endY = startY; | ||
this.startX = endX; | ||
this.startY = endY; | ||
this.width = width; | ||
this.color = color; | ||
this.direction = direction; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
public void accept(IRenderingVisitor v) { | ||
v.visit(this); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/test/org/openscience/cdk/renderer/elements/ArrowElementTest.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) 2011 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* Contact: cdk-devel@lists.sourceforge.net | ||
* | ||
* This program 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; either version 2.1 of the License, or (at your option) | ||
* any later version. All we ask is that proper credit is given for our work, | ||
* which includes - but is not limited to - adding the above copyright notice to | ||
* the beginning of your source code files, and to any copyright notice that you | ||
* may distribute with programs based on this work. | ||
* | ||
* This program 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 this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
package org.openscience.cdk.renderer.elements; | ||
|
||
import java.awt.Color; | ||
|
||
import org.junit.BeforeClass; | ||
|
||
/** | ||
* @cdk.module test-renderbasic | ||
*/ | ||
public class ArrowElementTest extends AbstractElementTest { | ||
|
||
@BeforeClass | ||
public static void setup() { | ||
IRenderingElement element = new ArrowElement( | ||
0, 0, 1, 1, 1.0, true, Color.orange | ||
); | ||
setRenderingElement(element); | ||
} | ||
|
||
} |