4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui;
21 |
22 | import javax.swing.*;
23 |
24 | public class FocusGrabber implements Runnable {
25 | private JComponent component;
26 |
27 | public FocusGrabber(JComponent component) {
28 | this.component = component;
29 | }
30 |
31 | public void run() {
32 | component.grabFocus();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/config/ClimatePlate.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.config;
21 |
22 | public class ClimatePlate {
23 | private String name;
24 | private String location;
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String getLocation() {
35 | return location;
36 | }
37 |
38 | public void setLocation(String location) {
39 | this.location = location;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/AstrolabeGenerator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator;
21 |
22 | import com.wymarc.astrolabe.generator.gui.GeneratorGui;
23 |
24 | public class AstrolabeGenerator{
25 |
26 | public AstrolabeGenerator(){
27 | GeneratorGui gui = new GeneratorGui();
28 | }
29 |
30 |
31 | public static void main(String[] args) {
32 | javax.swing.SwingUtilities.invokeLater(new Runnable() {
33 | public void run() {
34 | new AstrolabeGenerator();
35 | }
36 | });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/com/wymarc/astrolabe/math/ThreePointCenterTest.java:
--------------------------------------------------------------------------------
1 | package com.wymarc.astrolabe.math;
2 |
3 | import junit.framework.TestCase;
4 |
5 | import java.awt.geom.Point2D;
6 |
7 | /**
8 | * Astrolabe Generator
9 | *
10 | * The Astrolabe Generator is free software; you can redistribute it
11 | * and/or modify it under the terms of the GNU General Public License
12 | * as published by the Free Software Foundation; either version 2 of
13 | * the License, or(at your option) any later version.
14 | *
15 | * The Astrolabe Generator is distributed in the hope that it will be
16 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 | *
24 | * Copyright (c) 2013 Timothy J. Mitchell
25 | *
26 | * @author Timothy J. Mitchell (aka Richard Wymarc)
27 | * @version 4.0
28 | */
29 | public class ThreePointCenterTest extends TestCase {
30 |
31 | ThreePointCenter test;
32 |
33 | public void setUp() throws Exception {
34 | super.setUp();
35 | Point2D.Double linePoint1 = new Point2D.Double(-10.0,0.0);
36 | Point2D.Double linePoint2 = new Point2D.Double(0.0,0.0);
37 | Point2D.Double linePoint3 = new Point2D.Double(10.0,0.0);
38 |
39 | test = new ThreePointCenter(linePoint1,linePoint2,linePoint3);
40 | }
41 |
42 | public void testGetCenter() throws Exception {
43 |
44 | }
45 |
46 | public void testGetRadius() throws Exception {
47 |
48 | }
49 |
50 | public void testIsCircle() throws Exception {
51 | assertTrue(!test.isCircle());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/config/ClimateSet.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.config;
21 |
22 | import java.util.ArrayList;
23 | import java.util.List;
24 |
25 | public class ClimateSet {
26 | private String name = "";
27 | private List climates;
28 |
29 | public ClimateSet() {
30 | climates = new ArrayList<>();
31 | }
32 |
33 | public String getLocationNames(){
34 | String result = "";
35 | for (ClimatePlate plate : climates){
36 | if (result.equals("")){
37 | result = plate.getName();
38 | }else{
39 | result = result + ", " + plate.getName();
40 | }
41 | }
42 | return result;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | public void addClimate(ClimatePlate plate){
54 | climates.add(plate);
55 | }
56 |
57 | public List getClimates(){
58 | return climates;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/com/wymarc/astrolabe/math/InterSectTest.java:
--------------------------------------------------------------------------------
1 | package com.wymarc.astrolabe.math;
2 |
3 | import junit.framework.TestCase;
4 |
5 | /**
6 | * Astrolabe Generator
7 | *
8 | * The Astrolabe Generator is free software; you can redistribute it
9 | * and/or modify it under the terms of the GNU General Public License
10 | * as published by the Free Software Foundation; either version 2 of
11 | * the License, or(at your option) any later version.
12 | *
13 | * The Astrolabe Generator is distributed in the hope that it will be
14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | *
22 | * Copyright (c) 2013 Timothy J. Mitchell
23 | *
24 | * @author Timothy J. Mitchell (aka Richard Wymarc)
25 | * @version 4.0
26 | */
27 | public class InterSectTest extends TestCase {
28 |
29 | InterSect test = new InterSect(0.0,0.0,10.0,10.0,0.0,10.0); // intersects
30 | InterSect test1 = new InterSect(0.0,0.0,10.0,25.0,0.0,10.0); // no intersection
31 |
32 | public void testGetXi() throws Exception {
33 |
34 | }
35 |
36 | public void testGetYi() throws Exception {
37 |
38 | }
39 |
40 | public void testGetXi_prime() throws Exception {
41 |
42 | }
43 |
44 | public void testGetYi_prime() throws Exception {
45 |
46 | }
47 |
48 | public void testGetAngle1() throws Exception {
49 |
50 | }
51 |
52 | public void testGetAngle2() throws Exception {
53 |
54 | }
55 |
56 | public void testGetIntersection() throws Exception {
57 | if (test.getIntersection() && !test1.getIntersection()){
58 | assertTrue(true);
59 | }else{
60 | assertTrue(false);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/ExitAction.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui;
21 |
22 | import java.awt.Frame;
23 | import java.awt.event.ActionEvent;
24 | import java.awt.event.KeyEvent;
25 | import java.awt.event.WindowEvent;
26 | import javax.swing.Action;
27 | import javax.swing.AbstractAction;
28 |
29 | /**
30 | * This class will create and dispatch a WINDOW_CLOSING event to the active
31 | * frame. As a result a request to close the frame will be made and any
32 | * WindowListener that handles the windowClosing event will be executed.
33 | * Since clicking on the "Close" button of the frame or selecting the "Close"
34 | * option from the system menu also invoke the WindowListener, this will
35 | * provide a common exit point for the application.
36 | */
37 | public class ExitAction extends AbstractAction
38 | {
39 | public ExitAction()
40 | {
41 | super("Exit");
42 | putValue( Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X) );
43 | }
44 |
45 | public void actionPerformed(ActionEvent e)
46 | {
47 | // Find the active frame before creating and dispatching the event
48 |
49 | for (Frame frame : Frame.getFrames())
50 | {
51 | if (frame.isActive())
52 | {
53 | WindowEvent windowClosing = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
54 | frame.dispatchEvent(windowClosing);
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The Astrolabe Generator
2 | A Java-based tool for generating EPS files for constructing astrolabes and related tools
3 |
4 | In support of my ongoing research project into medieval scientific instruments such as the astrolabe, I have created a tool to allow the design of custom astrolabes.
5 |
6 | ## Features:
7 |
8 | - Allows customization of the astrolabe with a wide variety of options.
9 | - Additional related instruments are available:
10 | - The Universal Astrolabe.
11 | - The Sine Quadrant.
12 | - The Horary Quadrant.
13 | - Java based (executable .jar).
14 | - Generates Encapsulated PostScript (eps) files.
15 | - Saves to zip or folder.
16 | - Prints to PostScript capable printers.
17 |
18 | ## Related projects:
19 |
20 | [HTML5 Simulators](https://github.com/wymarc/html5-simulators): Simulations of the astrolabe and sine quadrant.
21 |
22 | For more information visit:
23 |
24 | [The Astrolabe Project](http://www.astrolabeproject.com/)
25 |
26 | 
27 |
28 | ## Release History:
29 |
30 | 3.3:
31 |
32 | - Fixed bug in Arcs of the Signs. Both options now work.
33 | - Expanded options for the sine/cosine grid scale on the astrolabe back:
34 | - Grid divided by 60 or 100
35 | - Optional cosine lines
36 | - Arcs and radials
37 | - Lines for each degree option
38 | - Under the hood:
39 | - Version number displays in interface now pulled dynamically from pom.xml
40 | - Default folder for saving is now the folder the app was run from
41 | - Consolidated file handling in the FileHandler class
42 | - Updated to Java 1.8
43 |
44 | 3.2:
45 |
46 | - Fixed bug in the formatting of shadow square numbers
47 | - Added in an option to display all three twilight lines
48 | - Added the option of using a concentric calendar ring instead of the more common offset
49 | - Added the option to choose between a base 60 and the less used base 10 grid for the sine scale on the back
50 |
51 | 3.1:
52 |
53 | - Added Universal Astrolabe with optional rete
54 | - Added an optional Equation of Time scale to the back
55 | - Under the hood:
56 | - Added routine for right-justifying text
57 | - Fixed bug in Time Correction display
58 |
59 | 3.0:
60 |
61 | - Ported project back to Java
62 | - Moved source code to GITHUB
63 |
64 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/tabbedview/GeneratorTabbedPane.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.tabbedview;
21 |
22 | import javax.swing.*;
23 |
24 | public class GeneratorTabbedPane extends JTabbedPane {
25 | private FrontPanel frontPanel;
26 | private BackPanel backPanel;
27 | private RetePanel retePanel;
28 | private AstrolabeVariationsPanel astrolabeVariationsPanel;
29 | private ExtrasPanel extrasPanel;
30 | private QuadrantPanel quadrantPanel;
31 |
32 | public GeneratorTabbedPane(){
33 | super();
34 | addTab("Front", null, getFrontPanel(), "Front options");
35 | addTab("Back", null, getBackPanel(), "Back options");
36 | addTab("Rete and Rules", null, getRetePanel(), "Rete and Rules options");
37 | addTab("Astrolabe Variations", null, getAstrolabeVariationsPanel(), "Astrolabe Variations");
38 | addTab("Quadrants", null, getQuadrantPanel(), "Quadrants options");
39 | addTab("Extras", null, getExtrasPanel(), "Extras to add");
40 | }
41 |
42 | public FrontPanel getFrontPanel() {
43 | if(null == frontPanel){
44 | frontPanel = new FrontPanel();
45 | }
46 | return frontPanel;
47 | }
48 |
49 | public BackPanel getBackPanel() {
50 | if(null == backPanel){
51 | backPanel = new BackPanel();
52 | }
53 | return backPanel;
54 | }
55 |
56 | public RetePanel getRetePanel() {
57 | if(null == retePanel){
58 | retePanel = new RetePanel();
59 | }
60 | return retePanel;
61 | }
62 |
63 | public AstrolabeVariationsPanel getAstrolabeVariationsPanel() {
64 | if(null == astrolabeVariationsPanel){
65 | astrolabeVariationsPanel = new AstrolabeVariationsPanel();
66 | }
67 | return astrolabeVariationsPanel;
68 | }
69 |
70 | public ExtrasPanel getExtrasPanel() {
71 | if(null == extrasPanel){
72 | extrasPanel = new ExtrasPanel();
73 | }
74 | return extrasPanel;
75 | }
76 |
77 | public QuadrantPanel getQuadrantPanel() {
78 | if(null == quadrantPanel){
79 | quadrantPanel = new QuadrantPanel();
80 | }
81 | return quadrantPanel;
82 | }
83 |
84 | public void updateControls(){
85 | //todo
86 | frontPanel.updateControls();
87 | backPanel.updateControls();
88 | retePanel.updateControls();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.wymarc.astrolabe.generator
5 | AstrolabeGenerator
6 | jar
7 | 3.3
8 | AstrolabeGenerator
9 | http://maven.apache.org
10 |
11 | UTF-8
12 | 1.8
13 | 1.8
14 |
15 |
16 |
17 | junit
18 | junit
19 | 3.8.1
20 | test
21 |
22 |
23 |
24 |
25 | Windows Environment
26 |
27 |
28 | windows
29 |
30 |
31 |
32 |
33 |
34 | src/main/resources
35 | true
36 |
37 |
38 |
39 |
40 | org.apache.maven.plugins
41 | maven-compiler-plugin
42 | 2.3.2
43 |
44 | 1.8
45 | 1.8
46 |
47 |
48 |
49 | org.apache.maven.plugins
50 | maven-jar-plugin
51 | 2.3.2
52 |
53 |
54 |
55 | com.wymarc.astrolabe.generator.AstrolabeGenerator
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Linux Environment
65 |
66 |
67 | !windows
68 |
69 |
70 |
71 |
72 |
73 | src/main/resources
74 | true
75 |
76 |
77 |
78 |
79 | org.apache.maven.plugins
80 | maven-compiler-plugin
81 | 2.3.2
82 |
83 | 1.5
84 | 1.5
85 |
86 |
87 |
88 | org.apache.maven.plugins
89 | maven-jar-plugin
90 | 2.3.2
91 |
92 |
93 |
94 | com.wymarc.astrolabe.generator.AstrolabeGenerator
95 |
96 |
97 |
98 |
99 |
100 | org.codehaus.mojo
101 | exec-maven-plugin
102 | 1.3.2
103 |
104 |
105 | script-chmod
106 | install
107 |
108 | exec
109 |
110 |
111 | chmod
112 |
113 | +x
114 | ${project.basedir}/target/${project.artifactId}-${project.version}.jar
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/tabbedview/RetePanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.tabbedview;
21 |
22 | import com.wymarc.astrolabe.Astrolabe;
23 | import com.wymarc.astrolabe.generator.gui.GeneratorGui;
24 |
25 | import javax.swing.*;
26 | import java.awt.*;
27 | import java.awt.event.ActionEvent;
28 | import java.awt.event.ActionListener;
29 | import java.awt.event.MouseEvent;
30 | import java.awt.event.MouseListener;
31 |
32 | public class RetePanel extends JPanel implements ActionListener,MouseListener {
33 | private JComboBox reteOptionsCombo = null;
34 | private ThumbNail thumbNail = null;
35 |
36 | public RetePanel() {
37 | super();
38 | setLayout(new BorderLayout());
39 |
40 | JPanel leftPanel = new JPanel();
41 | leftPanel.setLayout(new BorderLayout());
42 |
43 | JPanel optionsPanel = new JPanel();
44 | optionsPanel.setLayout(new GridBagLayout());
45 |
46 | JLabel label = new JLabel("Rete style:");
47 | GridBagConstraints c = new GridBagConstraints();
48 | c.fill = GridBagConstraints.HORIZONTAL;
49 | c.insets = new Insets(5,10,5,5);
50 | c.gridx = 0;
51 | c.gridy = 0;
52 | optionsPanel.add(label,c);
53 | c.gridx = 1;
54 | c.gridy = 0;
55 | optionsPanel.add(getReteOptionsCombo(),c);
56 |
57 | leftPanel.add(optionsPanel, BorderLayout.NORTH);
58 | add(leftPanel,BorderLayout.WEST);
59 |
60 | add(getThumbNail(),BorderLayout.EAST);
61 | }
62 |
63 | public JPanel getThumbNail(){
64 | if (null == thumbNail){
65 | thumbNail = new ThumbNail();
66 | }
67 | return thumbNail.updateReteThumbNail();
68 | }
69 |
70 | private JComboBox getReteOptionsCombo(){
71 | if (null == reteOptionsCombo){
72 | reteOptionsCombo = new JComboBox<>(Astrolabe.RETEOPTIONS);
73 | reteOptionsCombo.setSelectedIndex(GeneratorGui.MY_ASTROLABE.getReteType());
74 | reteOptionsCombo.setToolTipText("Select type of rete");
75 | reteOptionsCombo.setActionCommand("Rete");
76 | reteOptionsCombo.addActionListener(this);
77 | reteOptionsCombo.addMouseListener(this);
78 | }
79 | return reteOptionsCombo;
80 | }
81 |
82 | public void updateControls(){
83 | getReteOptionsCombo().setSelectedIndex(GeneratorGui.MY_ASTROLABE.getReteType());
84 | getThumbNail().updateUI();
85 | }
86 |
87 | public void actionPerformed(ActionEvent e) {
88 | String cmd = e.getActionCommand();
89 |
90 | if (cmd.equals("Rete")) {
91 | GeneratorGui.MY_ASTROLABE.setReteType(getReteOptionsCombo().getSelectedIndex());
92 | getThumbNail().updateUI();
93 | }
94 | }
95 |
96 | public void mouseClicked(MouseEvent e) {
97 |
98 | }
99 |
100 | public void mousePressed(MouseEvent e) {
101 |
102 | }
103 |
104 | public void mouseReleased(MouseEvent e) {
105 |
106 | }
107 |
108 | public void mouseEntered(MouseEvent e) {
109 | String text = "";
110 | Object obj = e.getSource();
111 | if (obj instanceof JComboBox){
112 | text = ((JComboBox) obj).getToolTipText();
113 | }else if (obj instanceof JCheckBox){
114 | text = ((JCheckBox) obj).getToolTipText();
115 | }
116 |
117 | GeneratorGui.setStatusLabel(text);
118 | }
119 |
120 | public void mouseExited(MouseEvent e) {
121 | GeneratorGui.setStatusLabel("");
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/GeneratorMenuBar.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui;
21 |
22 | import com.wymarc.astrolabe.generator.config.AstrolabeExample;
23 |
24 | import javax.swing.*;
25 | import java.awt.event.KeyEvent;
26 | import java.util.List;
27 |
28 | public class GeneratorMenuBar extends JMenuBar {
29 | public GeneratorMenuBar(GeneratorGui generator) {
30 | JMenu menu;
31 | JMenuItem menuItem;
32 |
33 | menu = new JMenu("File");
34 | menu.setMnemonic(KeyEvent.VK_F);
35 | menu.getAccessibleContext().setAccessibleDescription("File operations");
36 | add(menu);
37 |
38 | menuItem = new JMenuItem("Save to folder", KeyEvent.VK_S);
39 | menuItem.getAccessibleContext().setAccessibleDescription("Save to folder");
40 | menuItem.addActionListener(generator);
41 | menu.add(menuItem);
42 |
43 | menuItem = new JMenuItem("Save to Zip", KeyEvent.VK_Z);
44 | menuItem.getAccessibleContext().setAccessibleDescription("Save to Zip");
45 | menuItem.addActionListener(generator);
46 | menu.add(menuItem);
47 |
48 | menuItem = new JMenuItem("Print all", KeyEvent.VK_P);
49 | menuItem.getAccessibleContext().setAccessibleDescription("Print all");
50 | menuItem.addActionListener(generator);
51 | menuItem.setEnabled(GeneratorGui.HAS_PRINTER_SUPPORT);
52 | menu.add(menuItem);
53 |
54 | menuItem = new JMenuItem("Print current view", KeyEvent.VK_C);
55 | menuItem.getAccessibleContext().setAccessibleDescription("Print current view");
56 | menuItem.addActionListener(generator);
57 | menuItem.setEnabled(GeneratorGui.HAS_PRINTER_SUPPORT);
58 | menu.add(menuItem);
59 |
60 | menu.addSeparator();
61 | menu.add( new ExitAction() );
62 |
63 | menu = new JMenu("Predefined Astrolabes");
64 | menu.setMnemonic(KeyEvent.VK_P);
65 | menu.getAccessibleContext().setAccessibleDescription("Predefined Astrolabes");
66 | menuItem.addActionListener(generator);
67 | add(menu);
68 |
69 | List astrolabeList = GeneratorGui.MY_CONFIG.getAstrolabeExamples();
70 | for (AstrolabeExample astrolabe:astrolabeList ){
71 | menuItem = new JMenuItem(astrolabe.getName());
72 | menuItem.getAccessibleContext().setAccessibleDescription(astrolabe.getName());
73 | menuItem.addActionListener(generator);
74 | menu.add(menuItem);
75 | }
76 |
77 | menu = new JMenu("Help");
78 | menu.setMnemonic(KeyEvent.VK_H);
79 | menu.getAccessibleContext().setAccessibleDescription("Help");
80 | menuItem.addActionListener(generator);
81 | add(menu);
82 |
83 | menuItem = new JMenuItem("About", KeyEvent.VK_A);
84 | menuItem.getAccessibleContext().setAccessibleDescription("About");
85 | menuItem.addActionListener(generator);
86 | menu.add(menuItem);
87 |
88 | menuItem = new JMenuItem("Program Help", KeyEvent.VK_P);
89 | menuItem.getAccessibleContext().setAccessibleDescription("Program Help");
90 | menuItem.addActionListener(generator);
91 | menu.add(menuItem);
92 |
93 | menuItem = new JMenuItem("Astrolabe Resources", KeyEvent.VK_R);
94 | menuItem.getAccessibleContext().setAccessibleDescription("Astrolabe Resources");
95 | menuItem.addActionListener(generator);
96 | menu.add(menuItem);
97 |
98 | menuItem = new JMenuItem("Assembly Instructions");
99 | menuItem.getAccessibleContext().setAccessibleDescription("Assembly Instructions");
100 | menuItem.addActionListener(generator);
101 | menu.add(menuItem);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/tabbedview/AstrolabeVariationsPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.tabbedview;
21 |
22 | import com.wymarc.astrolabe.generator.AstrolabeGenerator;
23 | import com.wymarc.astrolabe.generator.gui.GeneratorGui;
24 |
25 | import javax.swing.*;
26 | import java.awt.*;
27 | import java.awt.event.ActionEvent;
28 | import java.awt.event.ActionListener;
29 | import java.awt.event.MouseEvent;
30 | import java.awt.event.MouseListener;
31 |
32 | public class AstrolabeVariationsPanel extends JPanel implements ActionListener,MouseListener {
33 | private JCheckBox universalCheck = null;
34 |
35 | public AstrolabeVariationsPanel(){
36 | super();
37 | setLayout(new BorderLayout());
38 |
39 | JPanel leftPanel = new JPanel();
40 | leftPanel.setLayout(new BorderLayout());
41 |
42 | JPanel optionsPanel = new JPanel();
43 | optionsPanel.setLayout(new GridBagLayout());
44 |
45 | JLabel optionsLabel = new JLabel("Variations on the basic astrolabe:");
46 | GridBagConstraints c = new GridBagConstraints();
47 | c.fill = GridBagConstraints.HORIZONTAL;
48 | c.insets = new Insets(5,10,5,5);
49 | c.gridx = 0;
50 | c.gridy = 0;
51 | optionsPanel.add(optionsLabel,c);
52 | c.gridy++;
53 | optionsPanel.add(getUniversalCheck(),c);
54 | leftPanel.add(optionsPanel, BorderLayout.NORTH);
55 | add(leftPanel, BorderLayout.WEST);
56 |
57 | ImageIcon icon = createImageIcon("gui/images/misc/universal.png");
58 | JLabel iconLabel = new JLabel(icon);
59 | if (null != icon){
60 | iconLabel.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
61 | }
62 | add(iconLabel,BorderLayout.EAST);
63 | }
64 |
65 | /** Returns an ImageIcon, or null if the path was invalid. */
66 | private ImageIcon createImageIcon(String path) {
67 | java.net.URL imgURL = AstrolabeGenerator.class.getResource(path);
68 | if (imgURL != null) {
69 | return new ImageIcon(imgURL);
70 | } else {
71 | System.err.println("Couldn't find file: " + path);
72 | return null;
73 | }
74 | }
75 |
76 | private JCheckBox getUniversalCheck(){
77 | if (null == universalCheck){
78 | universalCheck = new JCheckBox("Universal Astrolabe");
79 | universalCheck.setSelected(GeneratorGui.MY_ASTROLABE.getPrintUniversalAstrolabe());
80 | universalCheck.setToolTipText("Include the files for the Universal Astrolabe");
81 | universalCheck.setActionCommand("Universal");
82 | universalCheck.addActionListener(this);
83 | universalCheck.addMouseListener(this);
84 | }
85 | return universalCheck;
86 | }
87 |
88 | public void actionPerformed(ActionEvent e) {
89 | String cmd = e.getActionCommand();
90 |
91 | if (cmd.equals("Universal")) {
92 | GeneratorGui.MY_ASTROLABE.setPrintUniversalAstrolabe(universalCheck.isSelected());
93 | }
94 | }
95 |
96 | public void mouseClicked(MouseEvent e) {
97 |
98 | }
99 |
100 | public void mousePressed(MouseEvent e) {
101 |
102 | }
103 |
104 | public void mouseReleased(MouseEvent e) {
105 |
106 | }
107 |
108 | public void mouseEntered(MouseEvent e) {
109 | String text = "";
110 | Object obj = e.getSource();
111 | if (obj instanceof JComboBox){
112 | text = ((JComboBox) obj).getToolTipText();
113 | }else if (obj instanceof JCheckBox){
114 | text = ((JCheckBox) obj).getToolTipText();
115 | }
116 |
117 | GeneratorGui.setStatusLabel(text);
118 | }
119 |
120 | public void mouseExited(MouseEvent e) {
121 | GeneratorGui.setStatusLabel("");
122 | }
123 |
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/dialogs/HelpDialog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.dialogs;
21 |
22 | import com.wymarc.astrolabe.generator.AstrolabeGenerator;
23 | import com.wymarc.astrolabe.generator.config.Config;
24 |
25 | import javax.swing.*;
26 | import javax.swing.border.EmptyBorder;
27 | import java.awt.*;
28 |
29 | public class HelpDialog extends JDialog {
30 | public HelpDialog(JFrame frame) {
31 | super(frame, true);
32 | init();
33 | pack();
34 | setLocationRelativeTo(frame);
35 | setVisible(true);
36 | }
37 |
38 | private void init() {
39 | setPreferredSize(new Dimension(600,400));
40 | setResizable(false);
41 | setLayout(new BorderLayout());
42 | setTitle("Help");
43 |
44 | add(getIcon(), BorderLayout.WEST);
45 | add(getTextPanel(), BorderLayout.EAST);
46 | add(getBottomPanel(), BorderLayout.SOUTH);
47 | }
48 |
49 | private JPanel getTextPanel(){
50 | JPanel textPanel = new JPanel();
51 | textPanel.setBorder(new EmptyBorder(0,0,0,15));
52 | textPanel.setLayout(new GridBagLayout());
53 | GridBagConstraints c = new GridBagConstraints();
54 | c.fill = GridBagConstraints.HORIZONTAL;
55 | c.insets = new Insets(5,10,5,5);
56 | c.gridx = 0;
57 | c.gridy = 0;
58 |
59 | JLabel title = new JLabel("The Astrolabe Generator");
60 | title.setHorizontalAlignment(JLabel.RIGHT);
61 | title.setFont(new Font("Times New Roman", Font.BOLD + Font.ITALIC, 20));
62 | title.setForeground(Color.BLUE);
63 | textPanel.add(title, c);
64 |
65 | JLabel version = new JLabel("Version " + Config.version);
66 | version.setHorizontalAlignment(JLabel.RIGHT);
67 | version.setFont(new Font("Times New Roman", Font.PLAIN, 12));
68 | c.gridy = 1;
69 | textPanel.add(version, c);
70 |
71 | JTextPane textArea = new JTextPane();
72 | textArea.setOpaque(false);
73 | textArea.setContentType("text/html");
74 | textArea.setEditable(false);
75 | String text = "This program will generate a set of PostScript files for ";
76 | text += "printing or other use. You will need to know your current ";
77 | text += "location in degrees, minutes and seconds (454545N 1232323E ";
78 | text += "for example).
";
79 | text += "See Help, Astrolabe Resources for links to software for ";
80 | text += "displaying and printing.";
81 | textArea.setText(text);
82 | c.gridy = 2;
83 | textPanel.add(textArea,c);
84 |
85 | return textPanel;
86 | }
87 |
88 | private JPanel getBottomPanel(){
89 | JPanel bottom = new JPanel();
90 | bottom.setBorder(new EmptyBorder(10,0,10,0));
91 | bottom.setLayout(new GridBagLayout());
92 | GridBagConstraints c = new GridBagConstraints();
93 | c.fill = GridBagConstraints.HORIZONTAL;
94 | c.insets = new Insets(0,20,0,20);
95 | c.gridx = 0;
96 | c.gridy = 0;
97 |
98 | JLabel contact1 = new JLabel("Project page: http://sourceforge.net/projects/astrolabegenera");
99 | contact1.setFont(new Font("Times New Roman", Font.PLAIN, 12));
100 | bottom.add(contact1,c);
101 |
102 | JLabel contact2 = new JLabel("Home page: http://astrolabeproject.com");
103 | contact2.setFont(new Font("Times New Roman", Font.PLAIN, 12));
104 | c.gridy = 1;
105 | bottom.add(contact2,c);
106 |
107 | c.gridx = 1;
108 | c.gridy = 1;
109 | JButton okayButton = new javax.swing.JButton("OK");
110 | okayButton.addActionListener(new java.awt.event.ActionListener() {
111 | public void actionPerformed(java.awt.event.ActionEvent evt) {
112 | okayButtonActionPerformed(evt);
113 | }
114 | });
115 | bottom.add(okayButton,c);
116 |
117 |
118 | return bottom;
119 | }
120 |
121 | private JLabel getIcon(){
122 | java.net.URL imgURL = AstrolabeGenerator.class.getResource("gui/images/logo.png");
123 | if (imgURL != null) {
124 | JLabel icon = new JLabel((new ImageIcon(imgURL)));
125 | icon.setBorder(new EmptyBorder(0,15,0,0));
126 | return icon;
127 | }
128 | return new JLabel();
129 | }
130 |
131 | private void okayButtonActionPerformed(java.awt.event.ActionEvent evt){
132 | this.dispose();
133 | }
134 |
135 | }
136 |
137 |
138 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/dialogs/ResourcesDialog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.dialogs;
21 |
22 | import com.wymarc.astrolabe.generator.AstrolabeGenerator;
23 | import com.wymarc.astrolabe.generator.config.Config;
24 |
25 | import javax.swing.*;
26 | import javax.swing.border.EmptyBorder;
27 | import java.awt.*;
28 |
29 | public class ResourcesDialog extends JDialog {
30 | public ResourcesDialog(JFrame frame) {
31 | super(frame, true);
32 | init();
33 | pack();
34 | setLocationRelativeTo(frame);
35 | setVisible(true);
36 | }
37 |
38 | private void init() {
39 | setPreferredSize(new Dimension(600,500));
40 | setResizable(false);
41 | setLayout(new BorderLayout());
42 | setTitle("Resources");
43 |
44 | add(getIcon(), BorderLayout.WEST);
45 | add(getTextPanel(), BorderLayout.EAST);
46 | add(getBottomPanel(), BorderLayout.SOUTH);
47 | }
48 |
49 | private JPanel getTextPanel(){
50 | JPanel textPanel = new JPanel();
51 | textPanel.setBorder(new EmptyBorder(0,0,0,15));
52 | textPanel.setLayout(new GridBagLayout());
53 | GridBagConstraints c = new GridBagConstraints();
54 | c.fill = GridBagConstraints.HORIZONTAL;
55 | c.insets = new Insets(5,10,5,5);
56 | c.gridx = 0;
57 | c.gridy = 0;
58 |
59 | JLabel title = new JLabel("The Astrolabe Generator");
60 | title.setHorizontalAlignment(JLabel.RIGHT);
61 | title.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 20));
62 | title.setForeground(Color.BLUE);
63 | textPanel.add(title,c);
64 |
65 | JLabel version = new JLabel("Version " + Config.version);
66 | version.setHorizontalAlignment(JLabel.RIGHT);
67 | version.setFont(new Font("Times New Roman", Font.PLAIN, 12));
68 | c.gridy = 1;
69 | textPanel.add(version,c);
70 |
71 | JTextPane textArea = new JTextPane();
72 | textArea.setOpaque(false);
73 | textArea.setContentType("text/html");
74 | textArea.setEditable(false);
75 | String text = "Useful Links:
";
76 | text += "Project Page: ";
77 | text += "http://sourceforge.net/projects/astrolabegenera/
";
78 | text += "Viewing PostScript files: ";
79 | text += "http://pages.cs.wisc.edu/~ghost/gsview/
";
80 | text += "Printing PostScript files: ";
81 | text += "http://www.lerup.com/printfile/
";
82 | text += "The Astrolabe Project website: ";
83 | text += "http://www.astrolabeproject.com
";
84 | textArea.setText(text);
85 | c.gridy = 2;
86 | textPanel.add(textArea,c);
87 | return textPanel;
88 | }
89 |
90 | private JPanel getBottomPanel(){
91 | JPanel bottom = new JPanel();
92 | bottom.setBorder(new EmptyBorder(10,0,10,0));
93 | bottom.setLayout(new GridBagLayout());
94 | GridBagConstraints c = new GridBagConstraints();
95 | c.fill = GridBagConstraints.HORIZONTAL;
96 | c.insets = new Insets(0,20,0,20);
97 | c.gridx = 0;
98 | c.gridy = 0;
99 |
100 | JLabel contact1 = new JLabel("Project page: http://sourceforge.net/projects/astrolabegenera");
101 | contact1.setFont(new Font("Times New Roman", Font.PLAIN, 12));
102 | bottom.add(contact1,c);
103 |
104 | JLabel contact2 = new JLabel("Home page: http://astrolabeproject.com");
105 | contact2.setFont(new Font("Times New Roman", Font.PLAIN, 12));
106 | c.gridy = 1;
107 | bottom.add(contact2,c);
108 |
109 | c.gridx = 1;
110 | c.gridy = 1;
111 | JButton okayButton = new javax.swing.JButton("OK");
112 | okayButton.addActionListener(new java.awt.event.ActionListener() {
113 | public void actionPerformed(java.awt.event.ActionEvent evt) {
114 | okayButtonActionPerformed(evt);
115 | }
116 | });
117 | bottom.add(okayButton,c);
118 |
119 |
120 | return bottom;
121 | }
122 |
123 | private JLabel getIcon(){
124 | java.net.URL imgURL = AstrolabeGenerator.class.getResource("gui/images/logo.png");
125 | if (imgURL != null) {
126 | JLabel icon = new JLabel((new ImageIcon(imgURL)));
127 | icon.setBorder(new EmptyBorder(0,15,0,0));
128 | return icon;
129 | }
130 | return new JLabel();
131 | }
132 |
133 | private void okayButtonActionPerformed(java.awt.event.ActionEvent evt){
134 | this.dispose();
135 | }
136 |
137 | }
138 |
139 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/math/ThreePointCenter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.math;
21 |
22 | import java.awt.geom.Point2D;
23 |
24 | /**
25 | * Given three points on a plain, this class will compute the common center and the radius
26 | * of the circle than is defined by those points
27 | *
28 | * Date: 1 October 2011
29 | * Author Timothy J. Mitchell (wymarc@gmail.com)
30 | *
31 | * (Modified from other sources-see below)
32 | *
33 | * This is modification based loosely on the C example code circle3 routine by
34 | * James Morrison published in The Astrolabe
35 | *
36 | * Notes:
37 | *
38 | * There are two boundary conditions that must be dealt with:
39 | * 1. If two of the points have the same y-axis co-ordinate (i.e. 12,7; 87,7)
40 | * this can cause a divide-by-zero error in the code
41 | *
42 | * 2. If all three points lie on the same line, there is no circle that they define.
43 | *
44 | */
45 | public class ThreePointCenter {
46 |
47 | private Point2D.Double center= new Point2D.Double(0,0);
48 | private double radius = 0;
49 | private Boolean isCircle = true;
50 |
51 | public Point2D.Double getCenter() {
52 | return this.center;
53 | }
54 |
55 | public double getRadius() {
56 | return this.radius;
57 | }
58 |
59 | public Boolean isCircle() {
60 | return this.isCircle;
61 | }
62 |
63 | public ThreePointCenter(Point2D.Double point1, Point2D.Double point2, Point2D.Double point3){
64 | Point2D.Double pointZ;
65 |
66 | double temp1;
67 | double temp2;
68 |
69 | double deltaX1;
70 | double deltaY1;
71 | double deltaX2;
72 | double deltaY2;
73 |
74 | // first check to see if the three points are on the same line
75 | // Use two points to derive the equation of a line between those points
76 | // then see if the third point is on that line
77 | if((point1.x == point2.x && point2.x == point3.x)||(point1.y == point2.y && point2.y == point3.y))
78 | {
79 | //is a straight horz or vert line
80 | this.isCircle = false;
81 | return;
82 | }
83 |
84 | //Check to make sure point2.x does not equal point3.x. if equal swap out for point3
85 | if (point2.x == point1.x)
86 | {
87 | // swap
88 | if (point2.x != point3.x)
89 | {
90 | // swap point2 and point3
91 | pointZ = point3;
92 | point3 = point2;
93 | point2 = pointZ;
94 | }else
95 | {
96 | // swap point1 and point3
97 | pointZ = point3;
98 | point3 = point1;
99 | point1 = pointZ;
100 | }
101 | }
102 |
103 | // now test to see if point3 is on the same line as point1 and point2
104 | double slope = (point2.y - point1.y) / (point2.x - point1.x);
105 | double intercept = point1.y - (slope * point1.x);
106 |
107 | if(point3.y == (slope * point3.x) + intercept) //y = mx+b
108 | {
109 | //all three points on one line
110 | this.isCircle = false;
111 | return;
112 | }
113 |
114 | // next check to see if point2.y is the same as point1.y or if
115 | // point3.y is the same as point1.y if so there is a divide-by-zero
116 | // problem that can be solved by swapping points around.
117 | // we check above to see if the points were on a horz or vert line, so if
118 | // point2.y is the same as point1.y then point3.y can't be etc
119 |
120 | if (point2.y == point1.y)
121 | {
122 | // swap point1 and point3
123 | pointZ = point3;
124 | point3 = point1;
125 | point1 = pointZ;
126 | } else if (point3.y == point1.y)
127 | {
128 | // swap point1 and point2
129 | pointZ = point2;
130 | point2 = point1;
131 | point1 = pointZ;
132 | }
133 |
134 | // Find point equidistant from point1, point2 and point 3
135 |
136 | deltaX1 = point2.x - point1.x;
137 | deltaY1 = point2.y - point1.y;
138 | temp1 = ((point2.x * point2.x) - (point1.x * point1.x) + (point2.y * point2.y) - (point1.y * point1.y)) / 2.0;
139 | deltaX2 = point3.x - point1.x;
140 | deltaY2 = point3.y - point1.y;
141 | temp2 = ((point3.x * point3.x) - (point1.x * point1.x) + (point3.y * point3.y) - (point1.y * point1.y)) / 2.0;
142 |
143 | // solve for X
144 | this.center.x = ((temp1 / deltaY1) - (temp2 / deltaY2)) / ((deltaX1 / deltaY1) - (deltaX2 / deltaY2));
145 |
146 | // solve for Y
147 | this.center.y = (temp1 - (deltaX1 * this.center.x)) / deltaY1;
148 |
149 | this.radius = Math.sqrt(((this.center.x - point1.x) * (this.center.x - point1.x)) + ((this.center.y - point1.y) * (this.center.y - point1.y)));
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/dialogs/AboutDialog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.dialogs;
21 |
22 | import com.wymarc.astrolabe.generator.AstrolabeGenerator;
23 | import com.wymarc.astrolabe.generator.config.Config;
24 |
25 | import javax.swing.*;
26 | import javax.swing.border.EmptyBorder;
27 | import java.awt.*;
28 |
29 |
30 | public class AboutDialog extends JDialog {
31 | public AboutDialog(JFrame frame) {
32 | super(frame, true);
33 | init();
34 | pack();
35 | setLocationRelativeTo(frame);
36 | setVisible(true);
37 | }
38 |
39 | private void init() {
40 | setPreferredSize(new Dimension(600,480));
41 | setResizable(false);
42 | setLayout(new BorderLayout());
43 | setTitle("About");
44 |
45 | add(getIcon(), BorderLayout.WEST);
46 | add(getTextPanel(), BorderLayout.EAST);
47 | add(getBottomPanel(), BorderLayout.SOUTH);
48 | }
49 |
50 | private JPanel getTextPanel(){
51 | JPanel textPanel = new JPanel();
52 | textPanel.setBorder(new EmptyBorder(0,0,0,15));
53 | textPanel.setLayout(new GridBagLayout());
54 | GridBagConstraints c = new GridBagConstraints();
55 | c.fill = GridBagConstraints.HORIZONTAL;
56 | c.insets = new Insets(5,10,5,5);
57 | c.gridx = 0;
58 | c.gridy = 0;
59 |
60 | JLabel title = new JLabel("The Astrolabe Generator");
61 | title.setHorizontalAlignment(JLabel.RIGHT);
62 | title.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 20));
63 | title.setForeground(Color.BLUE);
64 | textPanel.add(title,c);
65 |
66 | JLabel version = new JLabel("Version " + Config.version);
67 | version.setHorizontalAlignment(JLabel.RIGHT);
68 | version.setFont(new Font("Times New Roman", Font.PLAIN, 12));
69 | c.gridy = 1;
70 | textPanel.add(version,c);
71 |
72 | JTextPane textArea = new JTextPane();
73 | textArea.setOpaque(false);
74 | textArea.setContentType("text/html");
75 | textArea.setEditable(false);
76 | // todo: set up text wrapping: http://stackoverflow.com/questions/4702891/toggling-text-wrap-in-a-jtextpane
77 | String text = "Dedicated to the memory of James E. Morrison author of The Astrolabe
";
78 | text += "The Astrolabe Generator is free software; you can ";
79 | text += "redistribute it and/or modify it under the terms of the ";
80 | text += "GNU General Public License as published by the Free ";
81 | text += "Software Foundation; either version 2 of the License, ";
82 | text += "or (at your option) any later version.
";
83 | text += "The Astrolabe Generator is distributed in the hope that ";
84 | text += "it will be useful, but WITHOUT ANY WARRANTY; without ";
85 | text += "even the implied warranty of MERCHANTABILITY or ";
86 | text += "FITNESS FOR A PARTICULAR PURPOSE. See the GNU ";
87 | text += "General Public License for more details.";
88 | textArea.setText(text);
89 | c.gridy = 2;
90 | textPanel.add(textArea,c);
91 |
92 | JLabel copyRight = new JLabel("Copyright(c) 2014 - 2017 Timothy J . Mitchell");
93 | copyRight.setFont(new Font("Times New Roman", Font.PLAIN, 12));
94 | c.gridy = 3;
95 | textPanel.add(copyRight,c);
96 |
97 | return textPanel;
98 | }
99 |
100 | private JPanel getBottomPanel(){
101 | JPanel bottom = new JPanel();
102 | bottom.setBorder(new EmptyBorder(10,0,10,0));
103 | bottom.setLayout(new GridBagLayout());
104 | GridBagConstraints c = new GridBagConstraints();
105 | c.fill = GridBagConstraints.HORIZONTAL;
106 | c.insets = new Insets(0,20,0,20);
107 | c.gridx = 0;
108 | c.gridy = 0;
109 |
110 | JLabel contact1 = new JLabel("Project page: http://sourceforge.net/projects/astrolabegenera");
111 | contact1.setFont(new Font("Times New Roman", Font.PLAIN, 12));
112 | bottom.add(contact1,c);
113 |
114 | JLabel contact2 = new JLabel("Home page: http://astrolabeproject.com");
115 | contact2.setFont(new Font("Times New Roman", Font.PLAIN, 12));
116 | c.gridy = 1;
117 | bottom.add(contact2,c);
118 |
119 | c.gridx = 1;
120 | c.gridy = 1;
121 | JButton okayButton = new javax.swing.JButton("OK");
122 | okayButton.addActionListener(new java.awt.event.ActionListener() {
123 | public void actionPerformed(java.awt.event.ActionEvent evt) {
124 | okayButtonActionPerformed(evt);
125 | }
126 | });
127 | bottom.add(okayButton,c);
128 |
129 |
130 | return bottom;
131 | }
132 |
133 | private JLabel getIcon(){
134 | java.net.URL imgURL = AstrolabeGenerator.class.getResource("gui/images/logo.png");
135 | if (imgURL != null) {
136 | JLabel icon = new JLabel((new ImageIcon(imgURL)));
137 | icon.setBorder(new EmptyBorder(0,15,0,0));
138 | return icon;
139 | }
140 | return new JLabel();
141 | }
142 |
143 | private void okayButtonActionPerformed(java.awt.event.ActionEvent evt){
144 | this.dispose();
145 | }
146 |
147 | }
148 |
149 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/printengines/postscript/extras/DemoArms.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.printengines.postscript.extras;
21 |
22 | import com.wymarc.astrolabe.generator.printengines.postscript.util.EPSToolKit;
23 |
24 | public class DemoArms {
25 |
26 | private String drawQuadrantScale(double scaleLength){
27 | String out = "";
28 | double interval1 = scaleLength/60.0;
29 | double interval5 = scaleLength/12.0;
30 |
31 | // draw scale
32 | out += "\n" + "0 0 moveto";
33 | out += "\n" + "0 15 lineto";
34 | out += "\n" + scaleLength + " 15 lineto";
35 | out += "\n" + scaleLength + " 0 lineto";
36 | out += "\n" + "0 0 lineto stroke";
37 | out += "\n" + "0 3 moveto";
38 | out += "\n" + scaleLength + " 3 lineto stroke";
39 |
40 | // mark and label
41 | out += "\n" + "NormalFont12 setfont";
42 | for (int i=1; i<=12; i++){
43 | out += "\n" + "newpath";
44 | out += "\n" + interval5*i + " 3 moveto";
45 | out += "\n" + interval5*i + " 15 lineto stroke";
46 | if (i>1){
47 | out += "\n" + (interval5*i-14) + " 5 moveto";
48 | }else{
49 | out += "\n" + (interval5*i-8) + " 5 moveto";
50 | }
51 | out += "\n" + "(" + (i*5) + ") show";
52 | }
53 | for (int i=1; i<=60; i++){
54 | out += "\n" + "newpath";
55 | out += "\n" + interval1*i + " 0 moveto";
56 | out += "\n" + interval1*i + " 3 lineto stroke";
57 | }
58 |
59 |
60 | // draw ends
61 | out += "\n" + scaleLength + " 15 moveto";
62 | out += "\n" + (scaleLength+24.0) + " 15 lineto stroke";
63 | out += "\n" + (scaleLength+24.0) + " 0 15 270 90 arc stroke";
64 | out += "\n" + (scaleLength+24.0) + " -15 moveto";
65 | out += "\n" + "0 -15 lineto stroke";
66 | out += "\n" + "0 0 15 90 270 arc stroke";
67 | out += "\n" + scaleLength + " 0 moveto";
68 | out += "\n" + (scaleLength+24.0) + " 0 lineto stroke";
69 | //draw pointer
70 | out += "\n" + (scaleLength+15.0) + " 0 moveto";
71 | out += "\n" + (scaleLength+24.0) + " 6 lineto";
72 | out += "\n" + (scaleLength+24.0) + " -6 lineto";
73 | out += "\n" + (scaleLength+15.0) + " 0 lineto fill";
74 |
75 | return out;
76 | }
77 |
78 | private String drawQuadrantOneSineScale(){
79 | String out = "";
80 | double scaleLength = 403.0;
81 | // draw box 403
82 | out += "\n" + "0 0 moveto";
83 | out += "\n" + "0 15 lineto";
84 | out += "\n" + scaleLength + " 15 lineto";
85 | out += "\n" + scaleLength + " 0 lineto";
86 | out += "\n" + "0 0 lineto stroke";
87 | out += "\n" + "0 5 moveto";
88 | out += "\n" + scaleLength + " 5 lineto stroke";
89 |
90 | // draw ends
91 | out += "\n" + scaleLength + " 15 moveto";
92 | out += "\n" + (scaleLength+15.0) + " 5 lineto";
93 | out += "\n" + (scaleLength+15.0) + " 0 lineto";
94 | out += "\n" + scaleLength + " 0 lineto stroke";
95 | out += "\n" + (scaleLength+15.0) + " 0 moveto";
96 | out += "\n" + (scaleLength+15.0) + " -15 lineto";
97 | out += "\n" + "0 -15 lineto stroke";
98 | out += "\n" + "0 0 15 90 270 arc stroke";
99 |
100 | //mark ticks
101 | double interval = scaleLength/100.0;
102 | for(int i = 1; i<100; i++){
103 | out += "\n" + interval*i + " 0 moveto";
104 | if(i == 10 || i == 20 || i == 30 || i == 40 || i == 50 || i == 60 || i == 70 || i == 80 || i == 90){
105 | out += "\n" + interval*i + " 15 lineto stroke";
106 | out += "\n" + "NormalFont8 setfont";
107 | out += "\n" + (interval*i) + " 7 moveto";
108 | out += EPSToolKit.centerText(i+"");
109 | }else{
110 | out += "\n" + interval*i + " 5 lineto stroke";
111 | }
112 | }
113 |
114 | return out;
115 | }
116 |
117 |
118 | public String printArms(){
119 | String out = "";
120 |
121 | // Write header to file
122 | out += "%!PS-Adobe-3.0 EPSF-30.";
123 | out += "\n" + "%%BoundingBox: 0 0 612 792";
124 | out += "\n" + "%%Title: Quadrant demo arms";
125 | out += "\n" + "%%Creator: Richard Wymarc";
126 | out += "\n" + "%%CreationDate: ";
127 | out += "\n" + "%%EndComments";
128 |
129 | out += "\n" + "mark";
130 | out += "\n" + "/Quadrant 10 dict def %local variable dictionary";
131 | out += "\n" + "Quadrant begin";
132 | out += "\n" + "";
133 | out += "\n" + "%% setup";
134 | out += EPSToolKit.fillBackground();
135 | out += "\n" + "72 730 translate";
136 | out += "\n" + ".4 setlinewidth";
137 | out += "\n" + "";
138 | out += EPSToolKit.setUpFonts();
139 | out += "\n" + "";
140 |
141 | for(int i = 1; i<5; i++){
142 | out += "\n" + "gsave";
143 | out += drawQuadrantScale(452.0);
144 | out += "\n" + "grestore";
145 | out += "\n" + "0 -60 translate";
146 | }
147 | for(int i = 1; i<5; i++){
148 | out += "\n" + "gsave";
149 | out += drawQuadrantScale(337.0);
150 | out += "\n" + "grestore";
151 | out += "\n" + "0 -60 translate";
152 | }
153 | for(int i = 1; i<5; i++){
154 | out += "\n" + "gsave";
155 | out += drawQuadrantOneSineScale();
156 | out += "\n" + "grestore";
157 | out += "\n" + "0 -60 translate";
158 | }
159 |
160 | // Write Footer
161 | out += "\n" + "% Eject the page";
162 | out += "\n" + "end cleartomark";
163 | out += "\n" + "showpage";
164 |
165 | return out;
166 |
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/Star.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe;
21 |
22 | import java.awt.geom.Point2D;
23 |
24 | /**
25 | * provides a source of star position data *
26 | */
27 | public class Star {
28 | public String name = "";
29 | public double ra = 0.0;
30 | public double dec = 0.0;
31 | public Point2D.Double base1 = new Point2D.Double();
32 | public Point2D.Double base2 = new Point2D.Double();
33 | public Point2D.Double labelPos = new Point2D.Double();
34 | public double labelOrient = 0.0;
35 |
36 |
37 | /**
38 | * Generates an array of Star objects
39 | * A Star object consists of:
40 | * name (String) The star's display name
41 | * ra (double) right ascension
42 | * dec (double) declination
43 | * base1 (Point2D.Double) position one base point of the rete pointer to the star
44 | * base2 (Point2D.Double) position for the other rete base point
45 | * labelPos (Point2D.Double) position for the label
46 | * labelOrient (double) label orientation
47 | *
48 | * @param hemiSphere N or S
49 | * @return Filled array of Star objects
50 | */
51 | public static Star[] getStarsList(String hemiSphere){
52 |
53 | Star[] starsList = new Star[17];
54 |
55 | if (hemiSphere.equals("S")){
56 | // show southern star set - Note Declination is reversed for the southern projection
57 | starsList[0] = new Star("Alpha Centaurus",14.75055556,-60.85277778,20,-10,10,-15,25,-7.5,0);
58 | starsList[1] = new Star("Canopus",6.542222222,-52.80555556,5,55,10,55,7.5,52.5,90);
59 | starsList[2] = new Star("Achernar",1.735833333,-57.26666667,-20,5,-15,15,-50,-7.5,0);
60 | starsList[3] = new Star("Altair",19.84636111,8.868333333,-60,-125,-70,-120,-68,-132,55);
61 | starsList[4] = new Star("Hamal",2.119527778,23.4625,0,0,0,0,-172,113,52);
62 | starsList[5] = new Star("Arcturus",14.261,19.1825,155,-95,160,-100,150,-90,-35);
63 | starsList[6] = new Star("Sirius",6.752472222,-16.71611111,5,100,5,90,7.5,90,90);
64 | starsList[7] = new Star("Procyon",7.655027778,5.225,62,125,57,125,50,127.5,-30);
65 | starsList[8] = new Star("Regulus",10.1395,11.96722222,0,0,0,0,130,85,-85);
66 | starsList[9] = new Star("Betelgeuse",5.919527778,7.406944444,-5,140,0,140,0,135,-5);
67 | starsList[10] = new Star("Rigel",5.242277778,-8.201666667,5,120,5,110,-5,111.5,0);
68 | starsList[11] = new Star("Bellatrix",5.418833333,6.349722222,-17,135,-25,135,-40,130.5,10);
69 | starsList[12] = new Star("Markab",23.07936111,15.20525,-200,-55,-195,-65,-202,-63,30);
70 | starsList[13] = new Star("Aldebaran",4.598666667,16.50916667,0,0,0,0,-87.5,147.5,40);
71 | starsList[14] = new Star("Spica",13.41986111,-11.16138889,0,0,0,0,80,-40,0);
72 | starsList[15] = new Star("Aliphard",9.459788889,-8.658602778,125,95,120,80,110,79,30);
73 | starsList[16] = new Star("Rosalhague",17.58225,12.56,5,-167,5,-160,2.5,-150,-90);
74 |
75 | }else{
76 | //show northern star set
77 | starsList[0] = new Star("Altair",19.84636111,8.868333333,-70,115,-60,125,-67.5,120,-59);
78 | starsList[1] = new Star("Capella",5.278138889,45.99805556,5,-50,5,-60,7,-60,90);
79 | starsList[2] = new Star("Arcturus",14.261,19.1825,120,20,130,40,93,43,-20);
80 | starsList[3] = new Star("Sirius",6.752472222,-16.71611111,10,-178,10,-170,3,-176,0);
81 | starsList[4] = new Star("Procyon",7.655027778,5.225,55,-125,65,-120,50,-130,30);
82 | starsList[5] = new Star("Deneb",20.6905,45.28027778,-5,35,-5,50,-18,40,0);
83 | starsList[6] = new Star("Vega",18.61561111,38.78361111,5,90,5,70,7,60,90);
84 | starsList[7] = new Star("Betelg",5.919527778,7.406944444,0,0,0,0,-3,-109,90);
85 | starsList[8] = new Star("Rigel",5.242277778,-8.201666667,-20,-135,-30,-135,-23,-137,-4);
86 | starsList[9] = new Star("Bellatrix",5.418833333,6.349722222,-30,-135,-45,-130,-55,-127,-18);
87 | starsList[10] = new Star("Markab",23.07936111,15.20525,-105,5,-95,5,-110,2,0);
88 | starsList[11] = new Star("Aldeb",4.598666667,16.50916667,-5,-100,-5,-115,-25,-98,-40);
89 | starsList[12] = new Star("Spica",13.41986111,-11.16138889,130,70,130,50,127,47,90);
90 | starsList[13] = new Star("Alioth",12.90044444,55.95983333,35,-5,45,-5,30,-7,0);
91 | starsList[14] = new Star("Aliphard",9.459788889,-8.658602778,115,-80,110,-85,102.5,-95,52);
92 | starsList[15] = new Star("Alpheca",15.57813889,26.71472222,5,75,5,60,15,65,0);
93 | starsList[16] = new Star("Rosalhague",17.58225,12.56,0,0,0,0,7,95,90);
94 | }
95 | return starsList;
96 | }
97 |
98 | /**
99 | * Constructor for the Star object
100 | *
101 | * @param name Name of the star
102 | * @param ra Right ascension
103 | * @param dec Declination
104 | * @param base1x x coordinate of first base point
105 | * @param base1y y coordinate of first base point
106 | * @param base2x x coordinate of second base point
107 | * @param base2y y coordinate of second base point
108 | * @param labelPosx x coordinate of label position
109 | * @param labelPosy y coordinate of label position
110 | * @param labelOrient Orientation of label 0-359
111 | *
112 | */
113 | public Star (String name,double ra, double dec, double base1x, double base1y,
114 | double base2x, double base2y, double labelPosx, double labelPosy, double labelOrient) {
115 | this.name = name;
116 | this.ra = ra;
117 | this.dec = dec;
118 | this.base1 = new Point2D.Double(base1x, base1y);
119 | this.base2 = new Point2D.Double(base2x,base2y);
120 | this.labelPos = new Point2D.Double(labelPosx,labelPosy);
121 | this.labelOrient = labelOrient;
122 | }
123 | /**
124 | * Default Constructor for the Star object
125 | *
126 | */
127 | public Star () {
128 | this.name = "";
129 | this. ra = 0.0;
130 | this. dec = 0.0;
131 | this. base1 = new Point2D.Double();
132 | this. base2 = new Point2D.Double();
133 | this. labelPos = new Point2D.Double();
134 | this. labelOrient = 0.0;
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/GeneratorToolBar.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui;
21 |
22 | import com.wymarc.astrolabe.Location;
23 | import com.wymarc.astrolabe.generator.AstrolabeGenerator;
24 |
25 | import javax.swing.*;
26 | import java.awt.*;
27 | import java.awt.event.FocusEvent;
28 | import java.awt.event.FocusListener;
29 | import java.awt.event.MouseEvent;
30 | import java.awt.event.MouseListener;
31 | import java.net.URL;
32 |
33 | public class GeneratorToolBar extends JToolBar implements MouseListener{
34 | private JTextField nameText = null;
35 | private JTextField locationNameText = null;
36 | private JTextField locationText = null;
37 |
38 |
39 | public GeneratorToolBar(GeneratorGui generator) {
40 | super();
41 | setFloatable(false);
42 | setRollover(true);
43 |
44 | JButton button = new JButton();
45 | //Look for the image.
46 | URL imageURL = AstrolabeGenerator.class.getResource("gui/images/icons/Save24.gif");
47 | button.setIcon(new ImageIcon(imageURL, "Save"));
48 | button.setActionCommand("Save to folder");
49 | button.setToolTipText("Save to Folder");
50 | button.addActionListener(generator);
51 | button.addMouseListener(this);
52 | add(button);
53 |
54 | button = new JButton();
55 | //Look for the image.
56 | imageURL = AstrolabeGenerator.class.getResource("gui/images/icons/SaveAsZip24.gif");
57 | button.setIcon(new ImageIcon(imageURL, "Save to Zip"));
58 | button.setActionCommand("Save to Zip");
59 | button.setToolTipText("Save to Zip");
60 | button.addActionListener(generator);
61 | button.addMouseListener(this);
62 | add(button);
63 |
64 | button = new JButton();
65 | //Look for the image.
66 | imageURL = AstrolabeGenerator.class.getResource("gui/images/icons/Print24.gif");
67 | button.setIcon(new ImageIcon(imageURL, "Print"));
68 | button.setActionCommand("Print all");
69 | button.setToolTipText("Print");
70 | button.addActionListener(generator);
71 | button.addMouseListener(this);
72 | button.setEnabled(GeneratorGui.HAS_PRINTER_SUPPORT);
73 | add(button);
74 |
75 | addSeparator();
76 |
77 | JPanel locationPanel = new JPanel();
78 | locationPanel.setLayout(new GridBagLayout());
79 | GridBagConstraints c = new GridBagConstraints();
80 | c.fill = GridBagConstraints.HORIZONTAL;
81 | c.insets = new Insets(5,5,5,5);
82 | c.gridx = 0;
83 | c.gridy = 0;
84 |
85 | JLabel nameLabel = new JLabel("Name:");
86 | nameText = getNameText();
87 | locationPanel.add(nameLabel,c);
88 | c.gridx = 1;
89 | locationPanel.add(nameText,c);
90 |
91 | JLabel locationNameLabel = new JLabel("Location name:");
92 | locationNameText = getLocationNameText();
93 | c.gridx = 2;
94 | locationPanel.add(locationNameLabel,c);
95 | c.gridx = 3;
96 | locationPanel.add(locationNameText,c);
97 |
98 | JLabel locationLabel = new JLabel("Location:");
99 | locationText = getLocationText();
100 | c.gridx = 4;
101 | locationPanel.add(locationLabel,c);
102 | c.gridx = 5;
103 | locationPanel.add(locationText,c);
104 |
105 | add(locationPanel);
106 | }
107 |
108 | public JTextField getNameText() {
109 | if (null == nameText){
110 | nameText = new JTextField("",10);
111 | nameText.setToolTipText("Name on astrolabe (optional)");
112 | nameText.addMouseListener(this);
113 | }
114 | return nameText;
115 | }
116 |
117 | public JTextField getLocationNameText() {
118 | if (null == locationNameText){
119 | locationNameText = new JTextField("",10);
120 | locationNameText.setToolTipText("Name of location (optional)");
121 | locationNameText.addMouseListener(this);
122 | }
123 | return locationNameText;
124 | }
125 |
126 | public JTextField getLocationText() {
127 | if (null == locationText){
128 | locationText = new JTextField("",12);
129 | locationText.setToolTipText("Location Coordinates (DDMMSSH DDDMMSSH)");
130 | locationText.addMouseListener(this);
131 | locationText.addFocusListener(new FocusListener() {
132 | public void focusGained(FocusEvent e) {}
133 | public void focusLost(FocusEvent e) {
134 | if (!e.isTemporary()) {
135 | if (!Location.isValidLocation(locationText.getText())) {
136 | locationText.setForeground(Color.RED);
137 | SwingUtilities.invokeLater(new FocusGrabber(locationText));
138 | JOptionPane.showMessageDialog(null, "Location must be in the format: ddmmssh dddmmssh. \n" +
139 | "for example, \n\n" +
140 | "45 degrees 30 minutes, 25 seconds North, \n" +
141 | "120 degrees, 40 minutes, 13 seconds West \n\n" +
142 | "would be: 453025N 1204013W","Location Error",JOptionPane.ERROR_MESSAGE);
143 | }else{
144 | locationText.setForeground(Color.BLACK);
145 | GeneratorGui.MY_ASTROLABE.getLocation().setLocation(locationText.getText());
146 | }
147 | }
148 | }
149 | });
150 | }
151 | return locationText;
152 | }
153 |
154 | public void mouseClicked(MouseEvent e) {
155 |
156 | }
157 |
158 | public void mousePressed(MouseEvent e) {
159 |
160 | }
161 |
162 | public void mouseReleased(MouseEvent e) {
163 |
164 | }
165 |
166 | public void mouseEntered(MouseEvent e) {
167 | String text = "";
168 | Object obj = e.getSource();
169 | if (obj instanceof JTextField){
170 | text = ((JTextField) obj).getToolTipText();
171 | }else if (obj instanceof JButton){
172 | text = ((JButton) obj).getToolTipText();
173 | }
174 |
175 | GeneratorGui.setStatusLabel(text);
176 | }
177 |
178 | public void mouseExited(MouseEvent e) {
179 | GeneratorGui.setStatusLabel("");
180 | }
181 |
182 | }
183 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/printengines/postscript/SineGrid.java:
--------------------------------------------------------------------------------
1 | package com.wymarc.astrolabe.generator.printengines.postscript;
2 |
3 | import com.wymarc.astrolabe.Astrolabe;
4 | import com.wymarc.astrolabe.math.AstroMath;
5 |
6 | public class SineGrid {
7 | private Astrolabe myAstrolabe = new Astrolabe();
8 |
9 | /**
10 | * computes and draws the Sin/Cos scale on the first quarter (top left)
11 | *
12 | * @return returns the ps code for drawing the SinCos Scale
13 | */
14 | public String buildSineGrid(){
15 |
16 | double myX;
17 | double myY; // X/Y Coordinates
18 | int i;
19 | String out = "";
20 |
21 | //compute size of arc that contains the scale and draw it
22 | // note eventually this will be done by looking at what rings are drawn and figuring
23 | // the remaining radius
24 | double radius = myAstrolabe.getMaterRadius() - 67;
25 |
26 | //Print outline of scale
27 |
28 | out += "\n" + "%% ================ Draw Sin/Cos Scale =================";
29 | out += "\n" + "newpath";
30 | out += "\n" + "0 0 moveto";
31 | out += "\n" + "0 " + radius + " lineto";
32 | out += "\n" + "0 0 " + radius + " 90 180 arc";
33 | out += "\n" + "0 0 lineto stroke";
34 |
35 | // By default we show just the Sine Scale
36 | out += "\n" + "%% ================ Draw Sin Scale =================";
37 | if (myAstrolabe.getGridPerDegree()){
38 | // draw by degree
39 | for (int j = 1; j < 90; j++){
40 | double angleR = Math.toRadians(j);
41 | double x = Math.sin(angleR)*radius;
42 | double y = Math.cos(angleR)*radius;
43 | out += "\n" + "newpath";
44 | out += "\n" + "0 " + y + " moveto";
45 | out += "\n" + -x + " " + y + " lineto stroke";
46 | }
47 | // mark sine divisions
48 | double step = radius/60.0;
49 | int divisions = 60;
50 | if (myAstrolabe.getUse100()){
51 | step = radius/50.0;
52 | divisions = 50;
53 | }
54 | for (i = 0; i <= divisions; i++) {
55 | if (i > 0 && i % 5 == 0 ){
56 | myY = step * i;
57 | out += "\n" + "newpath";
58 | out += "\n" + "0 " + myY + " moveto";
59 | out += "\n" + "2 " + myY + " lineto stroke";
60 | }
61 | }
62 | }else {
63 | double step = radius/60.0;
64 | int divisions = 60;
65 | if (myAstrolabe.getUse100()){
66 | step = radius/50.0;
67 | divisions = 50;
68 | }
69 |
70 | for (i = 0; i <= divisions; i++) {
71 | myY = step * i;
72 | myX = Math.sqrt((radius * radius) - (myY * myY)); // from circle eq
73 | out += "\n" + "newpath";
74 | if (i > 0 && i % 5 == 0 ){
75 | out += "\n" + "[2 2] 0 setdash"; //dash every 5th line
76 | }else{
77 | out += "\n" + "[] 0 setdash";
78 | }
79 | out += "\n" + "0 " + myY + " moveto";
80 | out += "\n" + -myX + " " + myY + " lineto stroke";
81 | }
82 | }
83 |
84 | out += "\n" + "%% ================ Draw Cos Scale =================";
85 | if (myAstrolabe.getShowCosine()) {
86 | if (myAstrolabe.getGridPerDegree()) {
87 | // draw by degree
88 | for (int j = 1; j < 90; j++) {
89 | double angleR = Math.toRadians(j);
90 | double x = Math.sin(angleR) * radius;
91 | double y = Math.cos(angleR) * radius;
92 | out += "\n" + "newpath";
93 | out += "\n" + -x + " 0 moveto";
94 | out += "\n" + -x + " " + y + " lineto stroke";
95 | }
96 | // mark cosine divisions
97 | double step = radius/60.0;
98 | int divisions = 60;
99 | if (myAstrolabe.getUse100()){
100 | step = radius/50.0;
101 | divisions = 50;
102 | }
103 | for (i = 0; i <= divisions; i++) {
104 | if (i > 0 && i % 5 == 0 ){
105 | myX = step * i;
106 | out += "\n" + "newpath";
107 | out += "\n" + -myX + " 0 moveto";
108 | out += "\n" + -myX + " -2 lineto stroke";
109 | }
110 | }
111 | } else {
112 | double step = radius/60.0;
113 | int divisions = 60;
114 | if (myAstrolabe.getUse100()){
115 | step = radius/50.0;
116 | divisions = 50;
117 | }
118 |
119 | for (i = 0; i <= divisions; i++) {
120 | myX = step * i;
121 | myY = Math.sqrt((radius * radius) - (myX * myX)); // from circle eq
122 | out += "\n" + "newpath";
123 | if (i > 0 && i % 5 == 0 ){
124 | out += "\n" + "[2 2] 0 setdash"; //dash every 5th line
125 | }else{
126 | out += "\n" + "[] 0 setdash";
127 | }
128 | out += "\n" + -myX + " 0 moveto";
129 | out += "\n" + -myX + " " + myY + " lineto stroke";
130 | }
131 | }
132 | }
133 | out += "\n" + "[] 0 setdash";
134 |
135 | out += "\n" + "%% ================ Draw Radials =================";
136 | if (myAstrolabe.getShowRadials()) {
137 | for (int j = 1; j < 6; j++){
138 | double angleR = Math.toRadians(j * 15.0);
139 | double x = Math.sin(angleR)*radius;
140 | double y = Math.cos(angleR)*radius;
141 | out += "\n" + "newpath";
142 | out += "\n" + "0 0 moveto";
143 | out += "\n" + -x + " " + y + " lineto stroke";
144 | }
145 | }
146 |
147 | out += "\n" + "%% ================ Draw Arcs =================";
148 | if (myAstrolabe.getShowArcs()) {
149 | for (int j = 1; j < 9; j++){
150 | double angleR = Math.toRadians(j * 10.0);
151 | double r = Math.sin(angleR)*radius;
152 | out += "\n" + "newpath";
153 | out += "\n" + "0 0 " + r + " 90 180 arc stroke";
154 | }
155 | }
156 |
157 | out += "\n" + "%% ================ Draw Obliqity =================";
158 | if (myAstrolabe.getShowObliqityArc()) {
159 | double obl = AstroMath.obliquity(AstroMath.getT());
160 | double angleR = Math.toRadians(obl);
161 | double r = Math.sin(angleR)*radius;
162 | out += "\n" + "newpath";
163 | out += "\n" + "[3 3] 0 setdash";
164 | out += "\n" + "0 0 " + r + " 90 180 arc stroke";
165 | out += "\n" + "[] 0 setdash";
166 | }
167 |
168 | // todo: Need to add the scales to the axis
169 | out += "\n" + "%% ================ End Sin/Cos Scale =================";
170 |
171 | return out;
172 | }
173 |
174 |
175 | public SineGrid(Astrolabe myAstrolabe) {
176 | this.myAstrolabe = myAstrolabe;
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/math/InterSect.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.math;
21 |
22 | /**
23 | * Given two circles defined by center and radius, this class will return the intersection
24 | * points and intersection angles
25 | *
26 | * @author Timothy J. Mitchell (wymarc@hotmail.com) (Modified from other sources-see below)
27 | *
28 | * link http://astrolabeproject.com
29 | * link http://www.astrolabes.org
30 | *
31 | *
32 | * version 3.0
33 | *
34 | * This is a mashup of the following two routines with some of my own additions:
35 | * Some code ported from C xsect routine by James Morrison published in The Astrolabe: page 378-380
36 | * Most code ported from C circle_circle_intersection routine by Tim Voght
37 | * And then the lot ported back to Java.
38 | */
39 | public class InterSect {
40 |
41 | private double xi;
42 | private double yi;
43 | private double xi_prime;
44 | private double yi_prime;
45 | private double angle1;
46 | private double angle2;
47 | private Boolean intersection = false;
48 |
49 | public double getXi() {
50 | return xi;
51 | }
52 |
53 | public double getYi() {
54 | return yi;
55 | }
56 |
57 | public double getXi_prime() {
58 | return xi_prime;
59 | }
60 |
61 | public double getYi_prime() {
62 | return yi_prime;
63 | }
64 |
65 | public double getAngle1() {
66 | return Math.toDegrees(angle1);
67 | }
68 |
69 | public double getAngle2() {
70 | return Math.toDegrees(angle2);
71 | }
72 |
73 | public Boolean getIntersection() {
74 | return intersection;
75 | }
76 |
77 | private double polar ( double num, double den ){
78 | // Polar Arctangent
79 | double ang = Math.atan2( num , den );
80 | if (ang < 0.0)
81 | {
82 | ang = ang + 2.0 * Math.PI;
83 | }
84 |
85 | return ang;
86 | }
87 |
88 | /**
89 | * Computes Intersection of two circles
90 | *
91 | * @param x0 drawing circle center X
92 | * @param y0 drawing circle center Y
93 | * @param r0 drawing circle radius
94 | *
95 | * @param x1 clipping circle center X
96 | * @param y1 clipping circle center Y
97 | * @param r1 clipping circle radius
98 | *
99 | */
100 | public InterSect(double x0, double y0, double r0, double x1, double y1, double r1)
101 | {
102 | double a;
103 | double dx;
104 | double dy;
105 | double d;
106 | double h;
107 | double rx;
108 | double ry;
109 | double x2;
110 | double y2;
111 | double A1;
112 | double A2;
113 | double xi1;
114 | double yi1;
115 | double xi_prime1;
116 | double yi_prime1;
117 |
118 | /* dx and dy are the vertical and horizontal distances between
119 | * the circle centers.
120 | */
121 | dx = x1 - x0;
122 | dy = y1 - y0;
123 |
124 | /* Determine the straight-line distance between the centers. */
125 | d = Math.sqrt((dy*dy) + (dx*dx));
126 | //d = hypot(dx,dy); // Suggested by Keith Briggs
127 |
128 | /* Check for solvability. */
129 | if (d > (r0 + r1))
130 | {
131 | /* no solution. circles do not intersect. */
132 | this.intersection = false;
133 | return;
134 | }
135 | if (d < Math.abs(r0 - r1))
136 | {
137 | /* no solution. one circle is contained in the other */
138 | this.intersection = false;
139 | return;
140 | }
141 |
142 | /* 'point 2' is the point where the line through the circle
143 | * intersection points crosses the line between the circle
144 | * centers.
145 | */
146 |
147 | /* Determine the distance from point 0 to point 2. */
148 | a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ;
149 |
150 | /* Determine the coordinates of point 2. */
151 | x2 = x0 + (dx * a/d);
152 | y2 = y0 + (dy * a/d);
153 |
154 | /* Determine the distance from point 2 to either of the
155 | * intersection points.
156 | */
157 | h = Math.sqrt((r0*r0) - (a*a));
158 |
159 | /* Now determine the offsets of the intersection points from
160 | * point 2.
161 | */
162 | rx = -dy * (h/d);
163 | ry = dx * (h/d);
164 |
165 | /* Determine the absolute intersection points. */
166 | this.xi = x2 + rx;
167 | this.xi_prime = x2 - rx;
168 | this.yi = y2 + ry;
169 | this.yi_prime = y2 - ry;
170 |
171 | // Calculate intersection angles
172 | // first determine the intersections from the center of the circle to be drawn
173 | xi1 = this.xi-x0;
174 | xi_prime1 = this.xi_prime-x0;
175 | yi1 = this.yi-y0;
176 | yi_prime1 = this.yi_prime-y0;
177 |
178 | if ( xi1 != 0.0 )
179 | { //Calculate first angle
180 | A1 = polar( yi1 , xi1) ;
181 | }
182 | else
183 | {
184 | if ( yi1 > 0.0 )
185 | {
186 | A1 = (Math.PI/2.0); //x1 = 0 => a = 90 or 270
187 | }
188 | else
189 | {
190 | A1 = 3.0 * Math.PI / 2.0 ;
191 | }
192 | }
193 |
194 | if ( xi_prime1 != 0.0)
195 | {//Calculate second angle
196 | A2 = polar( yi_prime1 , xi_prime1 ) ;
197 | }
198 | else
199 | {
200 | if (yi_prime1 > 0.0) A2 = Math.PI / 2.0 ;
201 | else A2 = 3.0 * Math.PI / 2.0 ;
202 | }
203 |
204 | // Store returned values //TODO: WTF
205 | this.angle1 = A1;
206 | x1 = this.xi;
207 | y1 = this.yi;
208 | this.angle2 = A2;
209 | x2 = this.xi_prime;
210 | y2 = this.yi_prime;
211 |
212 | // Sort returned values
213 | if (this.angle1 > this.angle2)
214 | {
215 | //swap (angle1,angle2) ;
216 | double hold;
217 | hold = this.angle1;
218 | this.angle1=this.angle2;
219 | this.angle2=hold;
220 | //swap (x1,x2) ;
221 | hold = x1;
222 | x1=x2;
223 | x2=hold;
224 | //swap (y1,y2) ;
225 | hold = y1;
226 | y1=y2;
227 | y2=hold;
228 | }
229 | //System.out.println("Angle 1 = " + Math.toDegrees(angle1));
230 | //System.out.println("Angle 2 = " + Math.toDegrees(angle2));
231 | this.intersection = true; //Return shows there is an intersection
232 | }
233 | }
234 |
235 |
236 |
237 |
--------------------------------------------------------------------------------
/src/main/resources/com/wymarc/astrolabe/generator/astrolabe_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ${project.version}
5 |
6 |
7 | Pennsic War
8 | 405835N 0800809W
9 |
10 |
11 |
12 | Default Astrolabe
13 | true
14 | 0
15 | false
16 | true
17 | 0
18 | false
19 | true
20 | 0
21 | 2
22 | true
23 | true
24 | false
25 | 0
26 | false
27 | false
28 | false
29 | false
30 | false
31 | false
32 | false
33 | false
34 | false
35 | 1
36 | 1
37 | 1
38 | 3
39 | 0
40 | true
41 | false
42 | false
43 |
44 |
45 | Simplified Astrolabe
46 | true
47 | 0
48 | false
49 | true
50 | 0
51 | false
52 | true
53 | 0
54 | 3
55 | false
56 | false
57 | false
58 | 0
59 | false
60 | false
61 | false
62 | false
63 | false
64 | false
65 | false
66 | false
67 | false
68 | 0
69 | 0
70 | 0
71 | 0
72 | 1
73 | false
74 | false
75 | false
76 |
77 |
78 | Astrolabe for Basic Class
79 | true
80 | 0
81 | false
82 | true
83 | 0
84 | false
85 | true
86 | 0
87 | 2
88 | true
89 | true
90 | false
91 | 0
92 | false
93 | false
94 | false
95 | false
96 | false
97 | false
98 | false
99 | false
100 | false
101 | 1
102 | 1
103 | 1
104 | 3
105 | 0
106 | true
107 | false
108 | false
109 |
110 |
111 | Astrolabe for Advanced Class
112 | true
113 | 1
114 | false
115 | true
116 | 0
117 | false
118 | true
119 | 0
120 | 2
121 | true
122 | true
123 | true
124 | 0
125 | true
126 | true
127 | true
128 | true
129 | false
130 | false
131 | true
132 | true
133 | false
134 | 2
135 | 2
136 | 1
137 | 3
138 | 0
139 | true
140 | false
141 | false
142 |
143 |
144 | Modern Astrolabe
145 | true
146 | 0
147 | false
148 | true
149 | 0
150 | false
151 | true
152 | 0
153 | 2
154 | true
155 | true
156 | false
157 | 0
158 | false
159 | false
160 | false
161 | false
162 | false
163 | false
164 | false
165 | false
166 | false
167 | 0
168 | 0
169 | 0
170 | 0
171 | 2
172 | false
173 | true
174 | true
175 |
176 |
177 |
178 |
179 |
180 |
181 | Montreal
182 | 453000N
183 |
184 |
185 | New York
186 | 404200N
187 |
188 |
189 | Washington DC
190 | 385400N
191 |
192 |
193 | Dallas
194 | 324700N
195 |
196 |
197 | Mexico City
198 | 192600N
199 |
200 |
201 |
202 |
203 |
204 |
205 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/Location.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe;
21 |
22 | /**
23 | * provides a object for describing locations
24 | */
25 | public class Location
26 | {
27 | private double latitude;
28 | private double longitude;
29 | private String locationName;
30 |
31 | private int latDegrees;
32 | private int latMinutes;
33 | private int latSeconds;
34 | private String latHemisphere;
35 | private int lonDegrees;
36 | private int lonMinutes;
37 | private int lonSeconds;
38 | private String lonHemisphere;
39 |
40 | /**
41 | * constructor
42 | *
43 | * @param nameIn String Location name
44 | * @param lat double decimal latitude
45 | * @param lon double decimal longitude
46 | */
47 | public Location(String nameIn,double lat,double lon){
48 | latitude = lat;
49 | longitude = lon;
50 |
51 | if(nameIn == null){
52 | locationName = "";
53 | }else{
54 | locationName = nameIn;
55 | }
56 | }
57 |
58 | /**
59 | * constructor
60 | *
61 | * @param nameIn String Location name
62 | * @param latDeg int latitude degrees
63 | * @param latMin int latitude minutes
64 | * @param latSec int latitude seconds
65 | * @param latDir String latitude direction (N/S)
66 | * @param lonDeg int longitude degrees
67 | * @param lonMin int longitude minutes
68 | * @param lonSec int longitude seconds
69 | * @param lonDir String longitude direction (N/S)
70 | */
71 | public Location(String nameIn,int latDeg,int latMin,int latSec,String latDir,
72 | int lonDeg,int lonMin,int lonSec,String lonDir){
73 | setLocation(nameIn, latDeg, latMin, latSec, latDir, lonDeg, lonMin, lonSec, lonDir);
74 | }
75 |
76 | public Location(){
77 | latitude = 0.0;
78 | longitude = 0.0;
79 | locationName = "";
80 | }
81 |
82 | public void setLocation(String nameIn,int latDeg,int latMin,int latSec,String latDir,
83 | int lonDeg,int lonMin,int lonSec,String lonDir){
84 | latDegrees = latDeg;
85 | latMinutes = latMin;
86 | latSeconds = latSec;
87 | latHemisphere = latDir.toUpperCase();
88 | lonDegrees = lonDeg;
89 | lonMinutes = lonMin;
90 | lonSeconds = lonSec;
91 | lonHemisphere = lonDir.toUpperCase();
92 |
93 |
94 | latitude = (double)latDeg + ((double)latMin/60) + ((double)latSec/3600);
95 | longitude = (double)lonDeg + ((double)lonMin/60) + ((double)lonSec/3600);
96 |
97 | // Note: This current defaults to North and East
98 | if(latDir.toUpperCase().equals("S")){
99 | latitude = -latitude;
100 | }
101 | if(lonDir.toUpperCase().equals("W")){
102 | longitude = -longitude;
103 | }
104 |
105 | if(nameIn == null){
106 | locationName = "";
107 | }else{
108 | locationName = nameIn;
109 | }
110 | }
111 |
112 | public void setLocation(String locationIn){
113 | // assumes the location string has been tested for validity (format: ddmmssh dddmmssh)
114 | latDegrees = Integer.parseInt(locationIn.substring(0, 2));
115 | latMinutes = Integer.parseInt(locationIn.substring(2, 4));
116 | latSeconds = Integer.parseInt(locationIn.substring(4, 6));
117 | latHemisphere = locationIn.substring(6,7);
118 |
119 | lonDegrees = Integer.parseInt(locationIn.substring(8, 11));
120 | lonMinutes = Integer.parseInt(locationIn.substring(11, 13));
121 | lonSeconds = Integer.parseInt(locationIn.substring(13, 15));
122 | lonHemisphere = locationIn.substring(15,16);
123 |
124 |
125 |
126 | latitude = (double)latDegrees + ((double)latMinutes/60) + ((double)latSeconds/3600);
127 | longitude = (double)lonDegrees + ((double)lonMinutes/60) + ((double)lonSeconds/3600);
128 |
129 | // Note: This current defaults to North and East
130 | if(latHemisphere.toUpperCase().equals("S")) {
131 | latitude = -latitude;
132 | }
133 | if(lonHemisphere.toUpperCase().equals("W")){
134 | longitude = -longitude;
135 | }
136 | }
137 |
138 | public void setLocationName(String nameIn){
139 | locationName = nameIn;
140 | }
141 |
142 | public Double getLatitude() {
143 | return latitude;
144 | }
145 |
146 | public Double getLongitude() {
147 | return longitude;
148 | }
149 |
150 | public String getLocationName() {
151 | return locationName;
152 | }
153 |
154 | public String getDisplayString(){
155 | return convertLatitudeToString(latitude) + ' ' + convertLongitudeToString(longitude);
156 | }
157 |
158 | private String convertLatitudeToString(double latIn){
159 | String direction = "N";
160 | if(latIn < 0){
161 | direction = "S";
162 | }
163 | return convertToDMS(latIn) + direction;
164 | }
165 |
166 | private String convertLongitudeToString(double lonIn){
167 | String direction = "E";
168 | if(lonIn < 0){
169 | direction = "W";
170 | }
171 | String lon = convertToDMS(lonIn) + direction;
172 | if (lon.length() < 7){ //1202020W
173 | lon = "00" + lon;
174 | }else if (lon.length() < 8){
175 | lon = "0" + lon;
176 | }
177 | return lon;
178 | }
179 |
180 | private String convertToDMS(double d){
181 | String deg = "";
182 | String min = "";
183 | String sec = "";
184 |
185 | d = Math.abs(d);
186 |
187 | //degrees
188 | Integer i = (int)Math.floor(d);
189 | if (i < 10){
190 | deg = "0";
191 | }
192 | deg = deg + i;
193 |
194 | //minutes
195 | d = d - i;
196 | d = d * 60;
197 | i = (int)Math.floor(d);
198 | if (i < 10){
199 | min = "0";
200 | }
201 | min = min + i;
202 |
203 | //seconds
204 | d = d - i;
205 | d = d * 60;
206 | i = (int)Math.floor(d);
207 | if (i < 10){
208 | sec = "0";
209 | }
210 | sec = sec + i;
211 |
212 | return deg + min + sec;
213 | }
214 |
215 | public static boolean isValidLocation(String locationIn){
216 | String regex = "([0-8][0-9]|[9][0])([0-5][0-9]|[6][0])([0-5][0-9]|[6][0])[NS] ([0][0-9][0-9]|[0-1][0-8][0-9]|[1][8][0])([0-5][0-9]|[6][0])([0-5][0-9]|[6][0])[EW]";
217 | // first check format
218 | if (!locationIn.matches(regex)){
219 | return false;
220 | }
221 | // the regex does no filter out locations like: 904545N 1804545E so parse and test
222 | // from the regex we know the format is ddmmssh dddmmssh
223 | int latDeg = Integer.parseInt(locationIn.substring(0, 2));
224 | int latMin = Integer.parseInt(locationIn.substring(2, 4));
225 | int latSec = Integer.parseInt(locationIn.substring(4, 6));
226 |
227 | int lonDeg = Integer.parseInt(locationIn.substring(8, 11));
228 | int lonMin = Integer.parseInt(locationIn.substring(11, 13));
229 | int lonSec = Integer.parseInt(locationIn.substring(13,15));
230 |
231 | if ((latDeg == 90) && (latMin > 0 || latSec > 0) ){
232 | return false;
233 | }
234 |
235 | return !((lonDeg == 180) && (lonMin > 0 || lonSec > 0));
236 | }
237 |
238 | public int getLatDeg(){
239 | return latDegrees;
240 | }
241 |
242 | public int getLatMin(){
243 | return latMinutes;
244 | }
245 |
246 | public int getLatSec(){
247 | return latSeconds;
248 | }
249 |
250 | public String getLatDir(){
251 | return latHemisphere;
252 | }
253 |
254 | public int getLonDeg(){
255 | return lonDegrees;
256 | }
257 |
258 | public int getLonMin(){
259 | return lonMinutes;
260 | }
261 |
262 | public int getLonSec(){
263 | return lonSeconds;
264 | }
265 |
266 | public String getLonDir(){
267 | return lonHemisphere;
268 | }
269 |
270 | }
271 |
272 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/gui/tabbedview/ExtrasPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.gui.tabbedview;
21 |
22 | import com.wymarc.astrolabe.generator.AstrolabeGenerator;
23 | import com.wymarc.astrolabe.generator.gui.GeneratorGui;
24 |
25 | import javax.swing.*;
26 |
27 | import java.awt.*;
28 | import java.awt.event.ActionEvent;
29 | import java.awt.event.ActionListener;
30 | import java.awt.event.MouseEvent;
31 | import java.awt.event.MouseListener;
32 |
33 | public class ExtrasPanel extends JPanel implements ActionListener,MouseListener {
34 | private JCheckBox tenAlidadeCheck = null;
35 | private JCheckBox tenRuleCheck = null;
36 | private JCheckBox counterChangedCheck = null;
37 |
38 | public ExtrasPanel() {
39 | super();
40 | setLayout(new BorderLayout());
41 |
42 | JPanel leftPanel = new JPanel();
43 | leftPanel.setLayout(new BorderLayout());
44 |
45 | JPanel optionsPanel = new JPanel();
46 | optionsPanel.setLayout(new GridBagLayout());
47 |
48 | JLabel optionsLabel = new JLabel("Multi-piece sheets (handy for making a lot of astrolabes):");
49 | GridBagConstraints c = new GridBagConstraints();
50 | c.fill = GridBagConstraints.HORIZONTAL;
51 | c.insets = new Insets(5,10,5,5);
52 | c.gridx = 0;
53 | c.gridy = 0;
54 | optionsPanel.add(optionsLabel,c);
55 | c.gridy++;
56 | optionsPanel.add(getTenAlidadeCheck(),c);
57 | c.gridy++;
58 | optionsPanel.add(getTenRuleCheck(),c);
59 | c.gridy++;
60 | optionsPanel.add(getCounterChangedCheck(),c);
61 |
62 | //todo
63 | // if (null != getClimateSetCheckboxes() && getClimateSetCheckboxes().size() > 0){
64 | // c.gridy++;
65 | // optionsPanel.add( new JSeparator(JSeparator.HORIZONTAL),c);
66 | // c.gridy++;
67 | // JLabel climateLabel = new JLabel("Climate plate sets (Interchangeable plates for major cities):");
68 | // optionsPanel.add(climateLabel,c);
69 | // c.gridy++;
70 | // JLabel climateLabel1 = new JLabel("(Plates will use the settings from the Front Tab)");
71 | // optionsPanel.add(climateLabel1,c);
72 | // for (JCheckBox ck : GeneratorGui.MY_ASTROLABE.getClimateSetCheckboxes()){
73 | // c.gridy++;
74 | // optionsPanel.add(ck,c);
75 | // }
76 | // }
77 |
78 | leftPanel.add(optionsPanel, BorderLayout.NORTH);
79 | add(leftPanel, BorderLayout.WEST);
80 |
81 | ImageIcon icon = createImageIcon("gui/images/misc/rulesthumb.png");
82 | JLabel iconLabel = new JLabel(icon);
83 | if (null != icon){
84 | iconLabel.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
85 | }
86 | add(iconLabel,BorderLayout.EAST);
87 | }
88 |
89 | /** Returns an ImageIcon, or null if the path was invalid. */
90 | private ImageIcon createImageIcon(String path) {
91 | java.net.URL imgURL = AstrolabeGenerator.class.getResource(path);
92 | if (imgURL != null) {
93 | return new ImageIcon(imgURL);
94 | } else {
95 | System.err.println("Couldn't find file: " + path);
96 | return null;
97 | }
98 | }
99 |
100 | private JCheckBox getTenAlidadeCheck(){
101 | if (null == tenAlidadeCheck){
102 | tenAlidadeCheck = new JCheckBox("10 alidade sheet");
103 | tenAlidadeCheck.setSelected(GeneratorGui.MY_ASTROLABE.getPrintAlidadeSheet());
104 | tenAlidadeCheck.setToolTipText("Include a ten alidade sheet");
105 | tenAlidadeCheck.setActionCommand("Alidade");
106 | tenAlidadeCheck.addActionListener(this);
107 | tenAlidadeCheck.addMouseListener(this);
108 | }
109 | return tenAlidadeCheck;
110 | }
111 |
112 | private JCheckBox getTenRuleCheck(){
113 | if (null == tenRuleCheck){
114 | tenRuleCheck = new JCheckBox("10 rule sheet");
115 | tenRuleCheck.setSelected(GeneratorGui.MY_ASTROLABE.getPrintRuleSheet());
116 | tenRuleCheck.setToolTipText("Include a ten rule sheet");
117 | tenRuleCheck.setActionCommand("Rule");
118 | tenRuleCheck.addActionListener(this);
119 | tenRuleCheck.addMouseListener(this);
120 | }
121 | return tenRuleCheck;
122 | }
123 |
124 | private JCheckBox getCounterChangedCheck(){
125 | if (null == counterChangedCheck){
126 | counterChangedCheck = new JCheckBox("Counterchange alidades");
127 | counterChangedCheck.setSelected(GeneratorGui.MY_ASTROLABE.isCounterChanged());
128 | counterChangedCheck.setToolTipText("Counterchange the offset of the arms");
129 | counterChangedCheck.setActionCommand("Counterchange");
130 | counterChangedCheck.addActionListener(this);
131 | counterChangedCheck.addMouseListener(this);
132 | }
133 | return counterChangedCheck;
134 | }
135 |
136 | // todo
137 | // private List getClimateSetCheckboxes(){
138 | // if (null == GeneratorGui.MY_ASTROLABE.getClimateSetCheckboxes()){
139 | // List climateSetCheckboxes = new ArrayList();
140 | // List climateSets = GeneratorGui.MY_CONFIG.getClimateSets();
141 | // for (ClimateSet set : climateSets){
142 | // JCheckBox temp = new JCheckBox(set.getName());
143 | // //temp.setSelected(GeneratorGui.MY_ASTROLABE.isCounterChanged());
144 | // temp.setToolTipText(set.getLocationNames());
145 | // climateSetCheckboxes.add(temp);
146 | // }
147 | // GeneratorGui.MY_ASTROLABE.setClimateSetCheckboxes(climateSetCheckboxes);
148 | // }
149 | // return GeneratorGui.MY_ASTROLABE.getClimateSetCheckboxes();
150 | // }
151 |
152 |
153 | public void actionPerformed(ActionEvent e) {
154 | String cmd = e.getActionCommand();
155 |
156 | if (cmd.equals("Alidade")) {
157 | GeneratorGui.MY_ASTROLABE.setPrintAlidadeSheet(tenAlidadeCheck.isSelected());
158 | }
159 |
160 | if (cmd.equals("Rule")) {
161 | GeneratorGui.MY_ASTROLABE.setPrintRuleSheet(tenRuleCheck.isSelected());
162 | }
163 |
164 | if (cmd.equals("Counterchange")) {
165 | GeneratorGui.MY_ASTROLABE.setCounterChanged(counterChangedCheck.isSelected());
166 | }
167 | }
168 |
169 | public void mouseClicked(MouseEvent e) {
170 |
171 | }
172 |
173 | public void mousePressed(MouseEvent e) {
174 |
175 | }
176 |
177 | public void mouseReleased(MouseEvent e) {
178 |
179 | }
180 |
181 | public void mouseEntered(MouseEvent e) {
182 | String text = "";
183 | Object obj = e.getSource();
184 | if (obj instanceof JComboBox){
185 | text = ((JComboBox) obj).getToolTipText();
186 | }else if (obj instanceof JCheckBox){
187 | text = ((JCheckBox) obj).getToolTipText();
188 | }
189 |
190 | GeneratorGui.setStatusLabel(text);
191 | }
192 |
193 | public void mouseExited(MouseEvent e) {
194 | GeneratorGui.setStatusLabel("");
195 | }
196 | }
197 |
--------------------------------------------------------------------------------
/src/main/java/com/wymarc/astrolabe/generator/printengines/postscript/extras/Dastur.java:
--------------------------------------------------------------------------------
1 | /**
2 | * $Id: AstrolabeGenerator.java,v 3.1
3 | *
4 | * The Astrolabe Generator is free software; you can redistribute it
5 | * and/or modify it under the terms of the GNU General Public License
6 | * as published by the Free Software Foundation; either version 3 of
7 | * the License, or(at your option) any later version.
8 | *
9 | * The Astrolabe Generator is distributed in the hope that it will be
10 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program; if not, write to the Free Software
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 | *
18 | * Copyright (c) 2017 Timothy J. Mitchell
19 | */
20 | package com.wymarc.astrolabe.generator.printengines.postscript.extras;
21 |
22 | import com.wymarc.astrolabe.generator.printengines.postscript.util.EPSToolKit;
23 |
24 | /**
25 | * This Plugin will calculate the lines of a dastur and
26 | * print the results to an Encapsulated PostScript (EPS) file. Note that
27 | * This file is static with no inputs. Software is included for reference.
28 | *