├── .gitignore ├── README.md └── src ├── com ├── .DS_Store └── jgoodies │ └── forms │ ├── builder │ ├── AbstractFormBuilder.java │ ├── ButtonBarBuilder.java │ ├── ButtonStackBuilder.java │ ├── DefaultFormBuilder.java │ ├── I15dPanelBuilder.java │ ├── PanelBuilder.java │ └── package.html │ ├── debug │ ├── FormDebugPanel.java │ ├── FormDebugUtils.java │ └── package.html │ ├── factories │ ├── Borders.java │ ├── ButtonBarFactory.java │ ├── ComponentFactory.java │ ├── DefaultComponentFactory.java │ ├── FormFactory.java │ └── package.html │ ├── layout │ ├── BoundedSize.java │ ├── CellConstraints.java │ ├── ColumnSpec.java │ ├── ConstantSize.java │ ├── FormLayout.java │ ├── FormSpec.java │ ├── RowSpec.java │ ├── Size.java │ ├── Sizes.java │ └── package.html │ └── util │ ├── AbstractUnitConverter.java │ ├── DefaultUnitConverter.java │ ├── LayoutStyle.java │ ├── MacLayoutStyle.java │ ├── UnitConverter.java │ ├── WindowsLayoutStyle.java │ └── package.html └── edu └── usfca ├── .DS_Store ├── vas ├── History.txt ├── ToDo.txt ├── VisualAutomataSimulator.java ├── app │ ├── About.java │ ├── Document.java │ ├── Localized.java │ ├── Preferences.java │ ├── Test.java │ └── UnitTests.java ├── data │ ├── DataAbstract.java │ ├── DataFA.java │ ├── DataTM.java │ ├── DataWrapperAbstract.java │ ├── DataWrapperFA.java │ └── DataWrapperTM.java ├── debug │ ├── DebugWrapper.java │ └── Debugger.java ├── graphics │ ├── IconManager.java │ ├── device │ │ ├── Console.java │ │ └── OutputDevice.java │ ├── fa │ │ ├── GElementFAMachine.java │ │ ├── GElementFAState.java │ │ └── GViewFAMachine.java │ └── tm │ │ ├── GElementTMMachine.java │ │ ├── GElementTMOperation.java │ │ └── GViewTMMachine.java ├── icons │ ├── .DS_Store │ ├── app.png │ ├── arrow.png │ ├── breakpoint.png │ ├── call.png │ ├── left.png │ ├── leftuntil.png │ ├── leftuntilnot.png │ ├── link.png │ ├── no.png │ ├── output.png │ ├── right.png │ ├── rightuntil.png │ ├── rightuntilnot.png │ ├── state.png │ ├── write.png │ └── yes.png ├── license.txt ├── machine │ ├── Tool.java │ ├── fa │ │ ├── FAAlphabet.java │ │ ├── FAMachine.java │ │ ├── FAState.java │ │ ├── FAStates.java │ │ ├── FATransition.java │ │ └── FATransitions.java │ └── tm │ │ ├── TMInterpretor.java │ │ ├── TMInterpretorStackElement.java │ │ ├── TMMachine.java │ │ ├── TMOperation.java │ │ ├── TMOperationLink.java │ │ ├── TMTape.java │ │ └── exception │ │ ├── TMException.java │ │ ├── TMInterpretorException.java │ │ └── TMTapeException.java ├── properties │ ├── about.properties │ └── strings.properties └── window │ ├── WindowAbstract.java │ ├── WindowMachineAbstract.java │ ├── batch │ ├── BatchTestTM.java │ ├── BatchTestTMItem.java │ └── BatchTestTMSettings.java │ ├── fa │ ├── WindowFA.java │ ├── WindowMachineFA.java │ ├── WindowMachineFAOverlay.java │ └── WindowMachineFASettings.java │ ├── tm │ ├── TapeConfiguration.java │ ├── TapeFavoriteContentsEditor.java │ ├── TapePanel.java │ ├── WindowMachineTM.java │ ├── WindowMachineTMSettings.java │ └── WindowTM.java │ └── tools │ ├── DesignToolsAbstract.java │ ├── DesignToolsFA.java │ └── DesignToolsTM.java └── xj ├── History.txt ├── appkit ├── .DS_Store ├── XJControl.java ├── app │ ├── .DS_Store │ ├── MacOS │ │ └── XJApplicationMacOS.java │ ├── XJAboutBox.java │ ├── XJApplication.java │ ├── XJApplicationDelegate.java │ ├── XJApplicationInterface.java │ └── XJPreferences.java ├── document │ ├── XJData.java │ ├── XJDataPlainText.java │ ├── XJDataXML.java │ ├── XJDocument.java │ └── XJDocumentType.java ├── frame │ ├── .DS_Store │ ├── XJDialog.java │ ├── XJFrame.java │ ├── XJFrameDelegate.java │ ├── XJFrameInterface.java │ ├── XJPanel.java │ ├── XJView.java │ └── XJWindow.java ├── gview │ ├── .DS_Store │ ├── GView.java │ ├── GViewDelegate.java │ ├── base │ │ ├── Anchor2D.java │ │ ├── Path2D.java │ │ ├── Rect.java │ │ └── Vector2D.java │ ├── event │ │ ├── GAbstractEvent.java │ │ ├── GEventCreateElement.java │ │ ├── GEventCreateLinkElement.java │ │ ├── GEventDelegate.java │ │ ├── GEventDragElement.java │ │ ├── GEventDragRootElement.java │ │ ├── GEventDragSelection.java │ │ ├── GEventEditElement.java │ │ ├── GEventFocusElement.java │ │ ├── GEventManager.java │ │ └── GEventModifyLinkElement.java │ ├── object │ │ ├── GElement.java │ │ ├── GElementArrow.java │ │ ├── GElementCircle.java │ │ ├── GElementLabel.java │ │ ├── GElementRect.java │ │ └── GLink.java │ ├── shape │ │ ├── SArrow.java │ │ ├── SLabel.java │ │ ├── SLink.java │ │ ├── SLinkArc.java │ │ ├── SLinkBezier.java │ │ ├── SLinkElbow.java │ │ ├── SLinkElbowBottomBottom.java │ │ ├── SLinkElbowBottomLeft.java │ │ ├── SLinkElbowLeftBottom.java │ │ ├── SLinkElbowLeftLeft.java │ │ ├── SLinkElbowLeftRight.java │ │ ├── SLinkElbowLeftTop.java │ │ ├── SLinkElbowTopBottom.java │ │ └── SLinkElbowTopLeft.java │ ├── timer │ │ ├── GTimer.java │ │ └── GTimerDelegate.java │ └── utils │ │ ├── GAlphaVariator.java │ │ ├── GDOTImporter.java │ │ ├── GDOTImporterDOT.java │ │ ├── GDOTImporterPlain.java │ │ └── GMagnetic.java ├── menu │ ├── XJMainMenuBar.java │ ├── XJMenu.java │ ├── XJMenuBarCustomizer.java │ ├── XJMenuBarDelegate.java │ ├── XJMenuItem.java │ ├── XJMenuItemCheck.java │ ├── XJMenuItemDelegate.java │ └── XJMenuItemSeparator.java ├── swing │ ├── XJColorChooser.java │ ├── XJGraphics2DPS.java │ ├── XJLookAndFeel.java │ ├── XJTable.java │ ├── XJTableDelegate.java │ ├── XJTree.java │ └── XJTreeDelegate.java ├── text │ ├── XJTextArea.java │ ├── XJTextField.java │ └── XJURLLabel.java ├── undo │ ├── .DS_Store │ ├── XJRedoAction.java │ ├── XJUndo.java │ ├── XJUndoAction.java │ ├── XJUndoDelegate.java │ └── XJUndoEngine.java ├── update │ ├── XJUpdateManager.java │ ├── XJUpdateManagerDelegate.java │ └── XJUpdateManagerDialogUpdateAvailable.java └── utils │ ├── BrowserLauncher.java │ ├── XJAlert.java │ ├── XJAlertInput.java │ ├── XJDialogProgress.java │ ├── XJDialogProgressDelegate.java │ ├── XJFileChooser.java │ ├── XJFileFilter.java │ ├── XJLocalizable.java │ └── XJSmoothScrolling.java ├── foundation ├── XJLib.java ├── XJObject.java ├── XJSystem.java ├── XJUtils.java ├── XJXMLSerializable.java ├── notification │ ├── XJNotificationCenter.java │ └── XJNotificationObserver.java └── timer │ ├── XJScheduledTimer.java │ └── XJScheduledTimerDelegate.java └── properties └── strings.properties /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.war 8 | *.ear 9 | 10 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 11 | hs_err_pid* 12 | 13 | # operating system files 14 | *~ 15 | 16 | # Netbeans files 17 | build.xml 18 | build/ 19 | dist/README.TXT 20 | manifest.mf 21 | nbproject/ 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Visual-Automata-Simulator 2 | ========================= 3 | 4 | This small application allows to create and simulate any Deterministic or Non-Deterministic Finite Automata (DFA or NFA) as well as Turing Machines (TM). 5 | 6 | Features 7 | -------- 8 | * Creates, simulates and transforms DFA and NFA machines 9 | * Creates and simulates TM 10 | * Batch tests for TM: useful features to test a bunch of files quickly! 11 | * Easy-to-use GUI interface (multi-documents) 12 | * Smart links between objects 13 | * Machines can be drawn using the mouse - and resized at any time 14 | * Multiple machines can be created in a single document 15 | * Multiple documents can be opened at the same time 16 | * Documents can be saved and reloaded from disk 17 | * Debug mode to see exactly how the machine is working (each step has a different color) 18 | * Export any machine to EPS file 19 | * Mac OS X GUI compliant 20 | 21 | Screenshots 22 | ----------- 23 | ![NFA accepting strings over {a, b, c} whose last symbol is unique](http://www.cs.usfca.edu/~jbovet/vas/screenshots/big/nfa.jpg) 24 | 25 | ![NFA accepting strings over {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} representing numbers evenly divisible by 4](http://www.cs.usfca.edu/~jbovet/vas/screenshots/big/nfa_2.jpg) 26 | 27 | ![A TM accepting strings with more a's than b's and more b's than c's](http://www.cs.usfca.edu/~jbovet/vas/screenshots/big/tm.jpg) 28 | 29 | ![A TM computing the modulo of two integers](http://www.cs.usfca.edu/~jbovet/vas/screenshots/big/tm_modulo.jpg) 30 | 31 | Credits 32 | ------- 33 | This was originally developed by [Jean Bovet](http://www.cs.usfca.edu/~jbovet/vas.html) and was uploaded here with his authorization because if i have some spare time in the future I inted to continue the development. 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/com/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/com/.DS_Store -------------------------------------------------------------------------------- /src/com/jgoodies/forms/builder/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 36 | 37 | 38 | 39 | Contains optional builder classes of the Forms framework. 40 | These non-visual builders assist you in building forms 41 | or in writing new form builder classes. 42 | 43 | 51 | 52 |

Related Documentation

53 | 54 | For more information see: 55 | 59 | 60 | 61 | @see com.jgoodies.forms.layout 62 | @see com.jgoodies.forms.factories 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/com/jgoodies/forms/debug/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 36 | 37 | 38 | 39 | Consists of optional classes that help you find, 40 | understand and fix layout problems. 41 | 42 | 50 | 51 |

Related Documentation

52 | 53 | For more information see: 54 | 58 | 59 | 60 | @see com.jgoodies.forms.layout 61 | @see com.jgoodies.forms.builder 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/com/jgoodies/forms/factories/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 36 | 37 | 38 | 39 | Consists of optional Forms framework factory classes that assist you 40 | in building consistent forms quickly. 41 | 42 | 50 | 51 |

Related Documentation

52 | 53 | For more information see: 54 | 58 | 59 | 60 | @see com.jgoodies.forms.layout 61 | @see com.jgoodies.forms.builder 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/com/jgoodies/forms/layout/Size.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2004 JGoodies Karsten Lentzsch. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * o Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * o Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * o Neither the name of JGoodies Karsten Lentzsch nor the names of 15 | * its contributors may be used to endorse or promote products derived 16 | * from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 28 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | package com.jgoodies.forms.layout; 32 | 33 | import java.awt.*; 34 | import java.util.List; 35 | 36 | /** 37 | * An interface that describes sizes as used by the {@link FormLayout}: 38 | * component measuring sizes, constant sizes with value and unit, 39 | * and bounded sizes that provide lower and upper bounds for a size.

40 | * 41 | * You can find a motivation for the different Size types in 42 | * the Forms article that is part of the product documentation and that is 43 | * available online too, see 44 | * 45 | * http://www.jgoodies.com/articles/forms.pdf. 46 | * 47 | * @author Karsten Lentzsch 48 | * @version $Revision: 1.5 $ 49 | * 50 | * @see Sizes 51 | * @see ConstantSize 52 | */ 53 | 54 | public interface Size { 55 | 56 | /** 57 | * Computes and returns my maximum size applied to the given list of 58 | * components using the specified measures.

59 | * 60 | * Invoked by {@link com.jgoodies.forms.layout.FormSpec} to determine 61 | * the size of a column or row. This method is not intended to be called 62 | * by API users, and it uses API invisible parameter types. 63 | * 64 | * @param container the layout container 65 | * @param components the list of components used to compute the size 66 | * @param minMeasure the measure that determines the minimum sizes 67 | * @param prefMeasure the measure that determines the preferred sizes 68 | * @param defaultMeasure the measure that determines the default sizes 69 | * @return the maximum size in pixels for the given list of components 70 | */ 71 | int maximumSize(Container container, 72 | List components, 73 | FormLayout.Measure minMeasure, 74 | FormLayout.Measure prefMeasure, 75 | FormLayout.Measure defaultMeasure); 76 | 77 | } -------------------------------------------------------------------------------- /src/com/jgoodies/forms/layout/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 36 | 37 | 38 | 39 | Contains the core classes of the JGoodies Forms framework: 40 | layout manager, column and row specifications, sizes and cell constraints. 41 | 42 | 50 | 51 |

Related Documentation

52 | 53 | For more information see: 54 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/com/jgoodies/forms/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 36 | 37 | 38 | 39 | Consists of Forms framework helper classes for unit conversion and layout styles. 40 | 41 | 49 | 50 |

Related Documentation

51 | 52 | For more information see: 53 | 57 | 58 | 59 | @see com.jgoodies.forms.builder 60 | @see com.jgoodies.forms.factories 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/edu/usfca/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/.DS_Store -------------------------------------------------------------------------------- /src/edu/usfca/vas/History.txt: -------------------------------------------------------------------------------- 1 | 2 | Version 1.2.2 - 11/24/06 3 | 4 | - updated with XJLibrary 1.2.7 5 | - fixed a bug where anchors of GElement were not updated after being loaded from disk 6 | 7 | Version 1.2.1 - 03/06/06 8 | 9 | - modified for XJLibrary 1.2.5 10 | - unit tests 11 | - fixed a bug introduced in version 1.1.2 with epsilon transition 12 | 13 | Version 1.2 - 11/13/05 14 | 15 | - FA and TM machine can be exported to EPS file 16 | - integrated update manager 17 | 18 | Version 1.1.2 - 11/01/05 19 | 20 | - preferences: can specify the character used to define an epsilon transition 21 | - fixed a bug where epsilon transition were not considered when starting 22 | directly from a state instead of following a non-epsilon transition 23 | 24 | Version 1.1.1 - 10/27/05 25 | 26 | - overlay in FA machine: display the string being consumed 27 | 28 | Version 1.1 - 10/01/05 29 | 30 | Improvement: 31 | 32 | - format of file has changed to XML (incompatible with version 1.0 but will support compatibility in the future) 33 | - image can now be saved to file (JPG, PNG or other format supported by Java) 34 | - "do nothing" at startup is no longer used on plateform other than MacOS 35 | - uses XJLib 1.2 36 | 37 | Bug fixes: 38 | 39 | - fixed a bug where alert and modal dialog would not stay in front on Windows/Linux 40 | - fixed a bug where the application would hang at startup when opening the last used document 41 | - fixed a bug where the preferences would be saved in a generic name 42 | - removed a dependency in GLink with machine.Tool 43 | - fixed some English strings 44 | 45 | Version 1.0 - 12/13/04 46 | 47 | - First release 48 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/ToDo.txt: -------------------------------------------------------------------------------- 1 | 2 | *** CheckList *** 3 | 4 | - check update manager properties in string.properties 5 | - update manager xml file online 6 | - run unit tests 7 | 8 | *** ToDo *** 9 | 10 | - help menu item is now handled by XJApplication 11 | 12 | - preferences: horizontal space when adding multiple operation from a pattern 13 | - button continue next to run in the TM/FA ? 14 | 15 | - localization in French 16 | - comments per machine 17 | - align to grid 18 | - make alignements between objects 19 | 20 | *** Windows/Linux 21 | 22 | - copy image doesn't works 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/app/Document.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.app; 33 | 34 | import edu.usfca.vas.data.DataAbstract; 35 | import edu.usfca.vas.data.DataWrapperAbstract; 36 | import edu.usfca.vas.window.WindowAbstract; 37 | import edu.usfca.xj.appkit.document.XJDocument; 38 | 39 | import java.util.Iterator; 40 | 41 | public class Document extends XJDocument { 42 | 43 | public Document() { 44 | } 45 | 46 | public void awake() { 47 | getAutomataWindow().setStateString(Localized.getString("automataReady")); 48 | } 49 | 50 | public WindowAbstract getAutomataWindow() { 51 | return (WindowAbstract)getWindow(); 52 | } 53 | 54 | public DataAbstract getAutomataData() { 55 | return (DataAbstract)getDocumentData(); 56 | } 57 | 58 | // *** XJDocument methods 59 | 60 | public void documentWillWriteData() { 61 | getAutomataWindow().documentWillWriteData(); 62 | } 63 | 64 | public void documentWillReadData() { 65 | getAutomataData().clear(); 66 | getAutomataWindow().clear(); 67 | } 68 | 69 | public void documentDidReadData() { 70 | int lastSelectedIndex = getAutomataData().getCurrentWrapperIndex(); 71 | 72 | getAutomataWindow().removeAllMachine(); 73 | 74 | Iterator iterator = getAutomataData().getWrappers().iterator(); 75 | while(iterator.hasNext()) { 76 | getAutomataWindow().createNewMachine((DataWrapperAbstract)iterator.next()); 77 | } 78 | 79 | getAutomataWindow().selectWindowMachineAtIndex(lastSelectedIndex); 80 | 81 | getAutomataWindow().documentDidReadData(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/app/Localized.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.app; 33 | 34 | import java.text.MessageFormat; 35 | import java.util.Locale; 36 | 37 | public class Localized { 38 | 39 | public static String getString(String key) { 40 | return edu.usfca.xj.appkit.utils.XJLocalizable.getString("strings", key); 41 | } 42 | 43 | public static String getFormattedString(String s, Object[] args) { 44 | MessageFormat formatter = new MessageFormat(""); 45 | formatter.setLocale(Locale.getDefault()); 46 | formatter.applyPattern(getString(s)); 47 | return formatter.format(args); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/data/DataAbstract.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.data; 33 | 34 | import edu.usfca.xj.appkit.document.XJDataXML; 35 | 36 | import java.beans.XMLDecoder; 37 | import java.beans.XMLEncoder; 38 | import java.util.ArrayList; 39 | import java.util.List; 40 | import java.util.Iterator; 41 | 42 | public abstract class DataAbstract extends XJDataXML { 43 | 44 | protected List wrappers = new ArrayList(); 45 | protected int currentWrapperIndex = -1; 46 | 47 | public DataAbstract() { 48 | } 49 | 50 | public DataWrapperAbstract getDataWrapperAtIndex(int index) { 51 | return (DataWrapperAbstract)wrappers.get(index); 52 | } 53 | 54 | public void removeDataWrapperAtIndex(int index) { 55 | wrappers.remove(index); 56 | } 57 | 58 | public void addWrapper(DataWrapperAbstract wrapper) { 59 | wrappers.add(wrapper); 60 | } 61 | 62 | public List getWrappers() { 63 | return wrappers; 64 | } 65 | 66 | public void setCurrentWrapperIndex(int index) { 67 | currentWrapperIndex = index; 68 | } 69 | 70 | public int getCurrentWrapperIndex() { 71 | return currentWrapperIndex; 72 | } 73 | 74 | public void clear() { 75 | wrappers.clear(); 76 | } 77 | 78 | public void customReadData(XMLDecoder d) { 79 | wrappers = (List)d.readObject(); 80 | currentWrapperIndex = ((Integer)d.readObject()).intValue(); 81 | 82 | for (Iterator iterator = wrappers.iterator(); iterator.hasNext();) { 83 | DataWrapperAbstract dataWrapper = (DataWrapperAbstract) iterator.next(); 84 | dataWrapper.wrapperDidLoad(); 85 | } 86 | } 87 | 88 | public void customWriteData(XMLEncoder e) { 89 | e.writeObject(wrappers); 90 | e.writeObject(new Integer(currentWrapperIndex)); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/data/DataFA.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.data; 33 | 34 | 35 | 36 | public class DataFA extends DataAbstract { 37 | 38 | public DataFA() { 39 | super(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/data/DataTM.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.data; 33 | 34 | import edu.usfca.vas.window.tm.TapeConfiguration; 35 | 36 | import java.util.ArrayList; 37 | import java.util.List; 38 | 39 | public class DataTM extends DataAbstract { 40 | 41 | public static final String KEY_TAPE_CONFIGS = "KEY_TAPE_CONFIGS"; 42 | public static final String KEY_DEFAULT_CONFIG = "KEY_DEFAULT_CONFIG"; 43 | 44 | public List getTapeConfigurations() { 45 | List configs = (List)getDataForKey(KEY_TAPE_CONFIGS); 46 | if(configs == null) { 47 | configs = new ArrayList(); 48 | setDataForKey(this, KEY_TAPE_CONFIGS, configs); 49 | } 50 | return configs; 51 | } 52 | 53 | public void setDefaultConfiguration(TapeConfiguration configuration) { 54 | setDataForKey(this, KEY_DEFAULT_CONFIG, configuration); 55 | } 56 | 57 | public TapeConfiguration getDefaultConfiguration() { 58 | return (TapeConfiguration)getDataForKey(KEY_DEFAULT_CONFIG); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/data/DataWrapperAbstract.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.data; 33 | 34 | import edu.usfca.vas.app.Localized; 35 | import edu.usfca.xj.foundation.XJObject; 36 | import edu.usfca.xj.foundation.XJXMLSerializable; 37 | 38 | public abstract class DataWrapperAbstract extends XJObject implements XJXMLSerializable { 39 | 40 | protected String name = Localized.getString("untitled"); 41 | 42 | protected int horizontalMagnetics = 4; 43 | protected int verticalMagnetics = 4; 44 | 45 | public DataWrapperAbstract() { 46 | super(); 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public void setMagnetics(int horizontal, int vertical) { 58 | setHorizontalMagnetics(horizontal); 59 | setVerticalMagnetics(vertical); 60 | } 61 | 62 | public void setHorizontalMagnetics(int value) { 63 | this.horizontalMagnetics = value; 64 | } 65 | 66 | public int getHorizontalMagnetics() { 67 | return horizontalMagnetics; 68 | } 69 | 70 | public void setVerticalMagnetics(int value) { 71 | this.verticalMagnetics = value; 72 | } 73 | 74 | public int getVerticalMagnetics() { 75 | return verticalMagnetics; 76 | } 77 | 78 | public void wrapperDidLoad() { 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/debug/DebugWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.debug; 33 | 34 | import edu.usfca.xj.appkit.gview.object.GElement; 35 | 36 | import java.awt.*; 37 | import java.util.ArrayList; 38 | import java.util.Iterator; 39 | import java.util.List; 40 | 41 | public class DebugWrapper { 42 | private List elements = new ArrayList(); 43 | 44 | public void addElement(GElement element) { 45 | elements.add(element); 46 | } 47 | 48 | public void addElements(List elements) { 49 | this.elements.addAll(elements); 50 | } 51 | 52 | public void setColor(Color color) { 53 | Iterator iterator = elements.iterator(); 54 | while(iterator.hasNext()) { 55 | GElement element = (GElement)iterator.next(); 56 | if(element != null) 57 | element.setColor(color); 58 | } 59 | } 60 | 61 | public void setPenSize(int size) { 62 | Iterator iterator = elements.iterator(); 63 | while(iterator.hasNext()) { 64 | GElement element = (GElement)iterator.next(); 65 | if(element != null) 66 | element.setPenSize(size); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/debug/Debugger.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.debug; 33 | 34 | import java.awt.*; 35 | import java.util.ArrayList; 36 | import java.util.Iterator; 37 | 38 | public class Debugger { 39 | 40 | private java.util.List historyElements = new ArrayList(); 41 | 42 | public void reset() { 43 | setHistoryColor(null); 44 | setHistoryPenSize(1); 45 | 46 | historyElements.clear(); 47 | } 48 | 49 | public void addHistory(DebugWrapper wrapper) { 50 | historyElements.add(wrapper); 51 | } 52 | 53 | public void setHistoryColor(Color color) { 54 | Iterator iterator = historyElements.iterator(); 55 | while(iterator.hasNext()) { 56 | DebugWrapper element = (DebugWrapper)iterator.next(); 57 | element.setColor(color); 58 | } 59 | } 60 | 61 | public void setHistoryPenSize(int size) { 62 | Iterator iterator = historyElements.iterator(); 63 | while(iterator.hasNext()) { 64 | DebugWrapper element = (DebugWrapper)iterator.next(); 65 | element.setPenSize(size); 66 | } 67 | } 68 | 69 | public void setHistoryGradientColor(Color color, Color startColor) { 70 | double i = 1.0/(historyElements.size()-1); 71 | double f = 0.0; 72 | Iterator iterator = historyElements.iterator(); 73 | while(iterator.hasNext()) { 74 | DebugWrapper element = (DebugWrapper)iterator.next(); 75 | Color cc = new Color((int)(color.getRed()*f), (int)(color.getGreen()*f), (int)(color.getBlue()*f)); 76 | if(f == 0) 77 | element.setColor(color); 78 | else 79 | element.setColor(cc); 80 | f += i; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/graphics/device/Console.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.graphics.device; 33 | 34 | import javax.swing.*; 35 | import javax.swing.text.SimpleAttributeSet; 36 | 37 | public class Console implements OutputDevice { 38 | 39 | private JScrollPane component; 40 | private JTextPane textArea; 41 | 42 | public Console() { 43 | textArea = new JTextPane(); 44 | component = new JScrollPane(textArea); 45 | } 46 | 47 | public JComponent getComponent() { 48 | return component; 49 | } 50 | 51 | public void clear() { 52 | textArea.setText(""); 53 | } 54 | 55 | public void print(String s) { 56 | String ps = textArea.getText(); 57 | textArea.setText(ps+s); 58 | System.out.print(s); 59 | } 60 | 61 | public void println(String s) { 62 | String ps = textArea.getText(); 63 | textArea.setText(ps+s+"\n"); 64 | System.out.println(s); 65 | } 66 | 67 | public void println(String t, SimpleAttributeSet attr) { 68 | String ps = textArea.getText(); 69 | textArea.setCaretPosition(ps.length()); 70 | textArea.setCharacterAttributes(attr, true); 71 | if(ps.length()>0) 72 | textArea.replaceSelection("\n"+t); 73 | else 74 | textArea.setText(t); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/graphics/device/OutputDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.graphics.device; 33 | 34 | import javax.swing.text.SimpleAttributeSet; 35 | 36 | public interface OutputDevice { 37 | public void clear(); 38 | 39 | public void print(String s); 40 | public void println(String s); 41 | 42 | public void println(String t, SimpleAttributeSet attr); 43 | } 44 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/.DS_Store -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/app.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/arrow.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/breakpoint.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/call.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/left.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/leftuntil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/leftuntil.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/leftuntilnot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/leftuntilnot.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/link.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/no.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/output.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/right.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/rightuntil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/rightuntil.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/rightuntilnot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/rightuntilnot.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/state.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/write.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/write.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/icons/yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/icons/yes.png -------------------------------------------------------------------------------- /src/edu/usfca/vas/license.txt: -------------------------------------------------------------------------------- 1 | [The "BSD licence"] 2 | Copyright (c) 2004-2006 Jean Bovet 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The name of the author may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/fa/FAAlphabet.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.fa; 33 | 34 | import edu.usfca.vas.app.Preferences; 35 | import edu.usfca.xj.foundation.XJXMLSerializable; 36 | 37 | import java.util.Iterator; 38 | import java.util.LinkedHashSet; 39 | import java.util.Set; 40 | 41 | public class FAAlphabet implements XJXMLSerializable { 42 | 43 | protected Set symbols = new LinkedHashSet(); 44 | protected transient FAMachine machine = null; 45 | 46 | public void setMachine(FAMachine machine) { 47 | this.machine = machine; 48 | } 49 | 50 | public void setSymbolsString(String s) { 51 | symbols.clear(); 52 | for(int c=0; c"; 94 | s += "< start = "+start+">"; 95 | s += "< accepted = "+accepted+">"; 96 | return s; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/fa/FATransition.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.fa; 33 | 34 | import edu.usfca.xj.foundation.XJXMLSerializable; 35 | 36 | public class FATransition implements XJXMLSerializable { 37 | 38 | public String s1; 39 | public String symbol; 40 | public String s2; 41 | 42 | public FATransition() { 43 | 44 | } 45 | 46 | public FATransition(String s1, String symbol, String s2) { 47 | this.s1 = s1; 48 | this.symbol = symbol; 49 | this.s2 = s2; 50 | } 51 | 52 | public String getS1() { 53 | return s1; 54 | } 55 | 56 | public void setS1(String s1) { 57 | this.s1 = s1; 58 | } 59 | 60 | public String getSymbol() { 61 | return symbol; 62 | } 63 | 64 | public void setSymbol(String symbol) { 65 | this.symbol = symbol; 66 | } 67 | 68 | public String getS2() { 69 | return s2; 70 | } 71 | 72 | public void setS2(String s2) { 73 | this.s2 = s2; 74 | } 75 | 76 | public String toString() { 77 | return "<"+s1+", "+symbol+" -> "+s2+">"; 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/tm/TMInterpretorStackElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.tm; 33 | 34 | public class TMInterpretorStackElement { 35 | 36 | private TMMachine machine = null; 37 | private TMOperation operation = null; 38 | 39 | public TMInterpretorStackElement(TMMachine machine, TMOperation op) { 40 | this.machine = machine; 41 | setOperation(op); 42 | } 43 | 44 | public TMMachine getMachine() { 45 | return machine; 46 | } 47 | 48 | public void setOperation(TMOperation op) { 49 | this.operation = op; 50 | } 51 | 52 | public TMOperation getOperation() { 53 | return operation; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/tm/TMOperationLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.tm; 33 | 34 | import edu.usfca.xj.foundation.XJXMLSerializable; 35 | 36 | import java.util.Set; 37 | 38 | 39 | public class TMOperationLink implements XJXMLSerializable { 40 | 41 | protected String symbol = ""; 42 | protected TMOperation sourceOperation = null; 43 | protected TMOperation targetOperation = null; 44 | protected Set variables = null; 45 | 46 | public TMOperationLink() { 47 | 48 | } 49 | 50 | public TMOperationLink(TMOperation source, TMOperation target, String symbol, Set variables) { 51 | this.sourceOperation = source; 52 | this.targetOperation = target; 53 | this.symbol = symbol; 54 | this.variables = variables; 55 | } 56 | 57 | public String getSymbol() { 58 | return symbol; 59 | } 60 | 61 | public void setSymbol(String symbol) { 62 | this.symbol = symbol; 63 | } 64 | 65 | public TMOperation getSourceOperation() { 66 | return sourceOperation; 67 | } 68 | 69 | public void setSourceOperation(TMOperation sourceOperation) { 70 | this.sourceOperation = sourceOperation; 71 | } 72 | 73 | public TMOperation getTargetOperation() { 74 | return targetOperation; 75 | } 76 | 77 | public void setTargetOperation(TMOperation targetOperation) { 78 | this.targetOperation = targetOperation; 79 | } 80 | 81 | public Set getVariables() { 82 | return variables; 83 | } 84 | 85 | public void setVariables(Set variables) { 86 | this.variables = variables; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/tm/exception/TMException.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.tm.exception; 33 | 34 | public class TMException extends Exception { 35 | public String message = null; 36 | } 37 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/tm/exception/TMInterpretorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.tm.exception; 33 | 34 | public class TMInterpretorException extends TMException { 35 | 36 | public TMInterpretorException(String message) { 37 | this.message = message; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/machine/tm/exception/TMTapeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.machine.tm.exception; 33 | 34 | public class TMTapeException extends TMException { 35 | 36 | public TMTapeException(String message) { 37 | this.message = message; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/properties/about.properties: -------------------------------------------------------------------------------- 1 | ABOUT_TITLE=About Visual Automata Simulator 2 | ABOUT_SOFTWARE_TITLE=Visual Automata Simulator 3 | ABOUT_SOFTWARE_VERSION=1.2.2 4 | ABOUT_SOFTWARE_VERSION_DATE=11/24/2006 5 | ABOUT_AUTHOR=Jean Bovet 6 | ABOUT_URL=http://cs.usfca.edu/~jbovet -------------------------------------------------------------------------------- /src/edu/usfca/vas/window/batch/BatchTestTM.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/vas/window/batch/BatchTestTM.java -------------------------------------------------------------------------------- /src/edu/usfca/vas/window/batch/BatchTestTMItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.window.batch; 33 | 34 | import edu.usfca.vas.app.Localized; 35 | 36 | public class BatchTestTMItem { 37 | 38 | public String file; 39 | public int machineCount; 40 | public int stepCount; 41 | public String tapeContent; 42 | public String result; 43 | public boolean failed; 44 | 45 | public BatchTestTMItem(String file) { 46 | this.file = file; 47 | } 48 | 49 | public static String getValueName(int col) { 50 | switch(col) { 51 | case 0: 52 | return Localized.getString("tmBatchItemFile"); 53 | case 1: 54 | return Localized.getString("tmBatchItemMachineCount"); 55 | case 2: 56 | return Localized.getString("tmBatchItemStepCount"); 57 | case 3: 58 | return Localized.getString("tmBatchItemTapeContent"); 59 | case 4: 60 | return Localized.getString("tmBatchItemStatus"); 61 | } 62 | return ""; 63 | } 64 | 65 | public void setValue(int col, String value) { 66 | switch(col) { 67 | case 0: 68 | file = value; 69 | break; 70 | case 1: 71 | tapeContent = value; 72 | break; 73 | } 74 | } 75 | 76 | public String getValue(int col) { 77 | switch(col) { 78 | case 0: 79 | return file; 80 | case 1: 81 | return String.valueOf(machineCount); 82 | case 2: 83 | return String.valueOf(stepCount); 84 | case 3: 85 | return tapeContent; 86 | case 4: 87 | return result; 88 | } 89 | return ""; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/window/tm/TapeConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.window.tm; 33 | 34 | import edu.usfca.vas.machine.tm.TMTape; 35 | import edu.usfca.vas.machine.tm.exception.TMTapeException; 36 | import edu.usfca.xj.foundation.XJXMLSerializable; 37 | 38 | public class TapeConfiguration implements XJXMLSerializable { 39 | 40 | public int position = 0; 41 | public String content = ""; 42 | 43 | public TapeConfiguration() { 44 | 45 | } 46 | 47 | public TapeConfiguration(TMTape tape) { 48 | tape.optimize(); 49 | setPosition(tape.getPosition()); 50 | setContent(tape.getContent()); 51 | } 52 | 53 | public int getPosition() { 54 | return position; 55 | } 56 | 57 | public void setPosition(int position) { 58 | this.position = position; 59 | } 60 | 61 | public String getContent() { 62 | return content; 63 | } 64 | 65 | public void setContent(String content) { 66 | this.content = content; 67 | } 68 | 69 | public void apply(TMTape tape) throws TMTapeException { 70 | tape.setPosition(position); 71 | tape.setContent(content); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/edu/usfca/vas/window/tools/DesignToolsFA.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2004 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.vas.window.tools; 33 | 34 | import edu.usfca.vas.app.Localized; 35 | import edu.usfca.vas.graphics.IconManager; 36 | 37 | import javax.swing.*; 38 | 39 | public class DesignToolsFA extends DesignToolsAbstract { 40 | 41 | public static final int TOOL_ARROW = 0; 42 | public static final int TOOL_LINK = 1; 43 | public static final int TOOL_STATE = 2; 44 | 45 | public DesignToolsFA() { 46 | setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); 47 | 48 | mouseButton = createDesignToolButton(IconManager.ICON_ARROW, Localized.getString("faDTSelect"), TOOL_ARROW); 49 | createDesignToolSeparator(20); 50 | createDesignToolButton(IconManager.ICON_LINK, Localized.getString("faDTLink"), TOOL_LINK); 51 | createDesignToolButton(IconManager.ICON_STATE, Localized.getString("faDTState"), TOOL_STATE); 52 | 53 | selectButton(mouseButton); 54 | } 55 | 56 | 57 | public String popSelectedStatePattern() { 58 | String s = (String)JOptionPane.showInputDialog(null, Localized.getString("faDTNewStateMessage"), 59 | Localized.getString("faDTNewStateTitle"), 60 | JOptionPane.QUESTION_MESSAGE, null, null, null); 61 | if(s != null) { 62 | consumeSelectedState(); 63 | } 64 | 65 | return s; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/xj/appkit/.DS_Store -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/XJControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit; 33 | 34 | import edu.usfca.xj.foundation.XJObject; 35 | 36 | public abstract class XJControl extends XJObject { 37 | 38 | private boolean enableKeyValueNotification = true; 39 | 40 | public void setEnableKeyValueNotification(boolean flag) { 41 | enableKeyValueNotification = flag; 42 | } 43 | 44 | public void keyValueChanged(String key, Object value) { 45 | if(enableKeyValueNotification) 46 | keyValueChanged(this, key, value); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/xj/appkit/app/.DS_Store -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/app/XJAboutBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.app; 33 | 34 | import edu.usfca.xj.appkit.frame.XJPanel; 35 | import edu.usfca.xj.appkit.utils.XJLocalizable; 36 | import edu.usfca.xj.foundation.XJLib; 37 | 38 | import javax.swing.*; 39 | import java.awt.*; 40 | 41 | public class XJAboutBox extends XJPanel { 42 | 43 | public static String getAboutSoftwareVersion() { 44 | return XJLocalizable.getString("about", "ABOUT_SOFTWARE_VERSION"); 45 | } 46 | 47 | public static String getAboutSoftwareVersionDate() { 48 | return XJLocalizable.getString("about", "ABOUT_SOFTWARE_VERSION_DATE"); 49 | } 50 | 51 | public static String getAboutURL() { 52 | return XJLocalizable.getString("about", "ABOUT_URL"); 53 | } 54 | 55 | public XJAboutBox() { 56 | setTitle(XJLocalizable.getString("about", "ABOUT_TITLE")); 57 | setSize(400, 200); 58 | jFrame.setResizable(false); 59 | 60 | JPanel panel = new JPanel(new GridBagLayout()); 61 | GridBagConstraints gbc = new GridBagConstraints(); 62 | 63 | JLabel label = new JLabel(XJLocalizable.getString("about", "ABOUT_SOFTWARE_TITLE")); 64 | label.setFont(new Font(label.getFont().getName(), Font.BOLD, 18)); 65 | 66 | gbc.gridx = 0; 67 | gbc.gridy = 0; 68 | 69 | panel.add(label, gbc); 70 | 71 | gbc.gridy = 1; 72 | panel.add(new JLabel(getAboutSoftwareVersion()+" "+getAboutSoftwareVersionDate()), gbc); 73 | 74 | gbc.gridy = 2; 75 | panel.add(new JLabel(" "), gbc); 76 | 77 | gbc.gridy = 3; 78 | label = new JLabel(XJLocalizable.getString("about", "ABOUT_AUTHOR")); 79 | panel.add(label, gbc); 80 | 81 | gbc.gridy = 4; 82 | label = new JLabel(XJLocalizable.getString("about", "ABOUT_URL")); 83 | panel.add(label, gbc); 84 | 85 | gbc.gridy = 5; 86 | panel.add(new JLabel(" "), gbc); 87 | 88 | gbc.gridy = 6; 89 | label = new JLabel("Built using XJLib "+XJLib.stringVersion()+" ("+XJLib.stringDate()+")"); 90 | panel.add(label, gbc); 91 | 92 | jFrame.getContentPane().add(panel, BorderLayout.CENTER); 93 | 94 | center(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/app/XJApplicationDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.app; 33 | 34 | import edu.usfca.xj.appkit.frame.XJPanel; 35 | import edu.usfca.xj.appkit.menu.XJMenu; 36 | 37 | public abstract class XJApplicationDelegate { 38 | public String appVersionShort() { return null; } 39 | public String appVersionLong() { return null; } 40 | public void appDidLaunch(String[] args) {} 41 | public void appWillTerminate() {} 42 | public Class appPreferencesPanelClass() { return null; } 43 | public XJPanel appInstanciateAboutPanel() { return null; } 44 | public void appShowHelp() {} 45 | public boolean appHasPreferencesMenuItem() { return false; } 46 | public boolean appShouldQuitAfterLastWindowClosed() { return false; } 47 | public Class appPreferencesClass() { return null; } 48 | public boolean supportsPersistence() { return true; } 49 | 50 | public void customizeFileMenu(XJMenu menu) { } 51 | 52 | public void customizeEditMenu(XJMenu menu) { } 53 | 54 | public void customizeWindowMenu(XJMenu menu) { } 55 | 56 | public void customizeHelpMenu(XJMenu menu) { } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/app/XJApplicationInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.app; 33 | 34 | import edu.usfca.xj.appkit.document.XJDocument; 35 | import edu.usfca.xj.appkit.frame.XJWindow; 36 | 37 | import java.util.List; 38 | 39 | public interface XJApplicationInterface { 40 | 41 | XJPreferences getPreferences(); 42 | 43 | boolean openDocument(); 44 | boolean openDocument(String file); 45 | boolean openLastUsedDocument(); 46 | 47 | XJDocument newDocumentOfData(Class dataClass); 48 | XJDocument newDocument(); 49 | void addDocument(XJDocument document); 50 | void removeDocument(XJDocument document); 51 | 52 | XJDocument getActiveDocument(); 53 | XJDocument getDocumentForPath(String path); 54 | List getDocumentExtensions(); 55 | List getDocuments(); 56 | 57 | void addWindow(XJWindow window); 58 | void removeWindow(XJWindow window); 59 | 60 | XJWindow getActiveWindow(); 61 | List getWindows(); 62 | 63 | boolean supportsPersistence(); 64 | 65 | boolean hasPreferencesMenuItem(); 66 | 67 | void addRecentFile(String path); 68 | void removeRecentFile(String file); 69 | void clearRecentFiles(); 70 | List recentFiles(); 71 | 72 | void performQuit(); 73 | 74 | void displayPrefs(); 75 | void displayAbout(); 76 | void displayHelp(); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/document/XJDataPlainText.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.document; 33 | 34 | import edu.usfca.xj.foundation.XJUtils; 35 | 36 | import java.io.FileOutputStream; 37 | import java.io.IOException; 38 | import java.io.OutputStream; 39 | 40 | public class XJDataPlainText extends XJData { 41 | 42 | public String text; 43 | 44 | public int dataType() { 45 | return DATA_PLAINTEXT; 46 | } 47 | 48 | public void readData() throws IOException, ClassNotFoundException { 49 | text = XJUtils.getStringFromFile(getFile()); 50 | } 51 | 52 | public void writeData() throws IOException { 53 | OutputStream os = new FileOutputStream(getFile()); 54 | os.write(text.getBytes()); 55 | os.close(); 56 | } 57 | 58 | public void setText(String text) { 59 | this.text = text; 60 | } 61 | 62 | public String getText() { 63 | return text; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/document/XJDataXML.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.document; 33 | 34 | import java.beans.XMLDecoder; 35 | import java.beans.XMLEncoder; 36 | import java.io.*; 37 | import java.util.Map; 38 | 39 | public class XJDataXML extends XJData { 40 | 41 | public int dataType() { 42 | return DATA_XML; 43 | } 44 | 45 | public void readData() throws IOException, ClassNotFoundException { 46 | XMLDecoder d = new XMLDecoder(new BufferedInputStream(new FileInputStream(getFile()))); 47 | dictionary = (Map)d.readObject(); 48 | customReadData(d); 49 | d.close(); 50 | } 51 | 52 | public void writeData() throws IOException { 53 | XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(getFile()))); 54 | e.writeObject(dictionary); 55 | customWriteData(e); 56 | e.close(); 57 | } 58 | 59 | public void customReadData(XMLDecoder d) { 60 | 61 | } 62 | 63 | public void customWriteData(XMLEncoder e) { 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/document/XJDocumentType.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.document; 33 | 34 | public class XJDocumentType { 35 | 36 | private Class documentClass = null; 37 | private Class windowClass = null; 38 | private Class dataClass = null; 39 | private String extension = null; 40 | private String description = null; 41 | 42 | public XJDocumentType(Class documentClass, Class windowClass, Class dataClass, String ext, String description) { 43 | this.documentClass = documentClass; 44 | this.windowClass = windowClass; 45 | this.dataClass = dataClass; 46 | this.extension = ext; 47 | this.description = description; 48 | } 49 | 50 | public Class getDocumentClass() { 51 | return documentClass; 52 | } 53 | 54 | public Class getWindowClass() { 55 | return windowClass; 56 | } 57 | 58 | public Class getDataClass() { 59 | return dataClass; 60 | } 61 | 62 | public String getExtension() { 63 | return extension; 64 | } 65 | 66 | public String getDescriptionString() { 67 | return description; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/frame/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/xj/appkit/frame/.DS_Store -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/frame/XJFrameDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.frame; 33 | 34 | public interface XJFrameDelegate { 35 | public void frameDidClose(XJFrame frame); 36 | } 37 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/frame/XJFrameInterface.java: -------------------------------------------------------------------------------- 1 | package edu.usfca.xj.appkit.frame; 2 | 3 | import javax.swing.*; 4 | 5 | import edu.usfca.xj.appkit.undo.XJUndo; 6 | import edu.usfca.xj.appkit.undo.XJUndoDelegate; 7 | import edu.usfca.xj.appkit.menu.XJMainMenuBar; 8 | import edu.usfca.xj.appkit.menu.XJMenu; 9 | import edu.usfca.xj.appkit.menu.XJMenuItem; 10 | 11 | import java.awt.*; 12 | /* 13 | 14 | [The "BSD licence"] 15 | Copyright (c) 2005-2006 Jean Bovet 16 | All rights reserved. 17 | 18 | Redistribution and use in source and binary forms, with or without 19 | modification, are permitted provided that the following conditions 20 | are met: 21 | 22 | 1. Redistributions of source code must retain the above copyright 23 | notice, this list of conditions and the following disclaimer. 24 | 2. Redistributions in binary form must reproduce the above copyright 25 | notice, this list of conditions and the following disclaimer in the 26 | documentation and/or other materials provided with the distribution. 27 | 3. The name of the author may not be used to endorse or promote products 28 | derived from this software without specific prior written permission. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 31 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 32 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 33 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 35 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 39 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | 41 | */ 42 | 43 | public interface XJFrameInterface { 44 | 45 | void registerUndo(XJUndoDelegate delegate, JTextPane textPane); 46 | XJUndo getUndo(JTextPane textPane); 47 | XJUndo getCurrentUndo(); 48 | 49 | XJMainMenuBar getMainMenuBar(); 50 | void handleMenuEvent(XJMenu menu, XJMenuItem item); 51 | 52 | Container getJavaContainer(); 53 | JLayeredPane getLayeredPane(); 54 | JRootPane getRootPane(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/frame/XJPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.frame; 33 | 34 | import edu.usfca.xj.appkit.menu.XJMainMenuBar; 35 | import edu.usfca.xj.appkit.menu.XJMenuItem; 36 | import edu.usfca.xj.foundation.XJSystem; 37 | 38 | public class XJPanel extends XJWindow { 39 | 40 | public XJPanel() { 41 | } 42 | 43 | public void menuItemState(XJMenuItem item) { 44 | super.menuItemState(item); 45 | 46 | switch(item.getTag()) { 47 | case XJMainMenuBar.MI_NEW: 48 | case XJMainMenuBar.MI_OPEN: 49 | case XJMainMenuBar.MI_CLOSE: 50 | item.setEnabled(XJSystem.isMacOS()); 51 | break; 52 | 53 | default: 54 | item.setEnabled(XJMainMenuBar.isRecentFilesItem(item)); 55 | } 56 | } 57 | 58 | public boolean shouldDisplayMainMenuBar() { 59 | return XJSystem.isMacOS(); 60 | } 61 | 62 | public boolean shouldAppearsInWindowMenu() { 63 | return false; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurifw/Visual-Automata-Simulator/583d18e2468f5894bd99a1027f99f30c40023241/src/edu/usfca/xj/appkit/gview/.DS_Store -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/GViewDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview; 33 | 34 | import edu.usfca.xj.appkit.gview.object.GElement; 35 | 36 | public interface GViewDelegate { 37 | public int getHorizontalMagnetics(); 38 | public int getVerticalMagnetics(); 39 | public void contextualHelp(GElement element); 40 | public void changeOccured(); 41 | public void viewSizeDidChange(); 42 | } 43 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/base/Anchor2D.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.base; 33 | 34 | import edu.usfca.xj.foundation.XJXMLSerializable; 35 | 36 | public class Anchor2D implements XJXMLSerializable { 37 | 38 | public static final Vector2D DIRECTION_FREE = new Vector2D(0, 0); 39 | public static final Vector2D DIRECTION_BOTTOM = new Vector2D(0, 1); 40 | public static final Vector2D DIRECTION_TOP = new Vector2D(0, -1); 41 | public static final Vector2D DIRECTION_LEFT = new Vector2D(-1, 0); 42 | public static final Vector2D DIRECTION_RIGHT = new Vector2D(1, 0); 43 | 44 | public Vector2D position = null; 45 | public Vector2D direction = null; 46 | 47 | public Anchor2D() { 48 | 49 | } 50 | 51 | public Anchor2D(Vector2D position, Vector2D direction) { 52 | setPosition(position); 53 | setDirection(direction); 54 | } 55 | 56 | public void setPosition(Vector2D position) { 57 | this.position = position; 58 | } 59 | 60 | public Vector2D getPosition() { 61 | return position; 62 | } 63 | 64 | public void setDirection(Vector2D direction) { 65 | this.direction = direction; 66 | } 67 | 68 | public Vector2D getDirection() { 69 | return direction; 70 | } 71 | 72 | public boolean equals(Object otherObject) { 73 | Anchor2D otherAnchor = (Anchor2D) otherObject; 74 | return position.equals(otherAnchor.position) && direction.equals(otherAnchor.direction); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/base/Path2D.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.base; 33 | 34 | import java.awt.*; 35 | import java.util.ArrayList; 36 | import java.util.Iterator; 37 | import java.util.List; 38 | 39 | public class Path2D { 40 | 41 | private List points = new ArrayList(); 42 | 43 | public Path2D() { 44 | 45 | } 46 | 47 | public void clear() { 48 | points.clear(); 49 | } 50 | 51 | public void add(Vector2D v) { 52 | points.add(v); 53 | } 54 | 55 | public void add(double x, double y) { 56 | add(new Vector2D(x, y)); 57 | } 58 | 59 | public void draw(Graphics g) { 60 | Vector2D lastV = null; 61 | 62 | Iterator iterator = points.iterator(); 63 | while(iterator.hasNext()) { 64 | Vector2D v = (Vector2D)iterator.next(); 65 | if(lastV != null) 66 | g.drawLine((int)lastV.getX(), (int)lastV.getY(), (int)v.getX(), (int)v.getY()); 67 | 68 | lastV = v; 69 | } 70 | } 71 | 72 | public boolean contains(double x, double y) { 73 | Vector2D oldv = null; 74 | Iterator iterator = points.iterator(); 75 | while(iterator.hasNext()) { 76 | Vector2D v = (Vector2D)iterator.next(); 77 | if(oldv != null) { 78 | Rect r = new Rect(oldv, v); 79 | r.inset(-4); 80 | if(r.contains(x, y)) 81 | return true; 82 | } 83 | oldv = v; 84 | } 85 | return false; 86 | } 87 | 88 | public Vector2D getEndDirection() { 89 | if(points.size()<2) 90 | return null; 91 | 92 | Vector2D v1 = (Vector2D)points.get(points.size()-2); 93 | Vector2D v2 = (Vector2D)points.get(points.size()-1); 94 | return v1.sub(v2); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/base/Rect.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.base; 33 | 34 | import java.awt.*; 35 | 36 | public class Rect { 37 | 38 | public Rectangle r; 39 | 40 | public Rect(Rectangle r) { 41 | this.r = r; 42 | } 43 | 44 | public Rect(Vector2D c1, Vector2D c2) { 45 | create(c1, c2, 0, 0); 46 | } 47 | 48 | public Rect(Vector2D c1, Vector2D c2, double min_dx, double min_dy) { 49 | create(c1, c2, min_dx, min_dy); 50 | } 51 | 52 | public void create(Vector2D c1, Vector2D c2, double min_dx, double min_dy) { 53 | double x = Math.min(c1.getX(), c2.getX()); 54 | double y = Math.min(c1.getY(), c2.getY()); 55 | double dx = Math.max(min_dx, Math.abs(c1.getX()-c2.getX())); 56 | double dy = Math.max(min_dy, Math.abs(c1.getY()-c2.getY())); 57 | r = new Rectangle((int)x, (int)y, (int)dx, (int)dy); 58 | } 59 | 60 | public Rect(double x, double y, double dx, double dy) { 61 | if(dx<0) { 62 | x += dx; 63 | dx = -dx; 64 | } 65 | if(dy<0) { 66 | y += dy; 67 | dy = -dy; 68 | } 69 | 70 | r = new Rectangle((int)x, (int)y, (int)dx, (int)dy); 71 | } 72 | 73 | public Rect union(Rect r) { 74 | return new Rect((Rectangle)rectangle().createUnion(r.rectangle())); 75 | } 76 | 77 | public Rectangle rectangle() { 78 | return r; 79 | } 80 | 81 | public static boolean intersect(Rect r1, Rect r2) { 82 | return r1.rectangle().intersects(r2.rectangle()); 83 | } 84 | 85 | public boolean contains(double x, double y) { 86 | return r.contains(x, y); 87 | } 88 | 89 | public boolean contains(Point p) { 90 | return r.contains(p); 91 | } 92 | 93 | public void inset(double f) { 94 | r.x += f; 95 | r.y += f; 96 | r.width -= 2*f; 97 | r.height -= 2*f; 98 | } 99 | 100 | public String toString() { 101 | if(r == null) 102 | return super.toString(); 103 | else 104 | return r.toString(); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GAbstractEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.GView; 35 | import edu.usfca.xj.appkit.gview.object.GElement; 36 | 37 | import java.awt.*; 38 | import java.awt.event.MouseEvent; 39 | 40 | public abstract class GAbstractEvent { 41 | 42 | protected GEventManager manager = null; 43 | protected GEventDelegate delegate = null; 44 | 45 | protected GView view = null; 46 | 47 | public GAbstractEvent(GView view) { 48 | this.view = view; 49 | } 50 | 51 | public void setDelegate(GEventDelegate delegate) { 52 | this.delegate = delegate; 53 | } 54 | 55 | public void setManager(GEventManager manager) { 56 | this.manager = manager; 57 | } 58 | 59 | public void addExclusiveValue(Object value) { 60 | manager.addExclusiveValue(value); 61 | } 62 | 63 | public void removeExclusiveValue(Object value) { 64 | manager.removeExclusiveValue(value); 65 | } 66 | 67 | public boolean hasExclusiveValue(Object value) { 68 | return manager.hasExclusiveValue(value); 69 | } 70 | 71 | public boolean shouldFocusOnElement(GElement element) { 72 | return true; 73 | } 74 | 75 | public void mousePressed(MouseEvent e, Point mousePosition) { 76 | 77 | } 78 | 79 | public void mouseReleased(MouseEvent e, Point mousePosition) { 80 | 81 | } 82 | 83 | public void mouseDragged(MouseEvent e, Point mousePosition) { 84 | 85 | } 86 | 87 | public void mouseMoved(MouseEvent e, Point mousePosition) { 88 | 89 | } 90 | 91 | public void draw(Graphics g) { 92 | 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GEventCreateElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.GView; 35 | import edu.usfca.xj.appkit.gview.object.GElement; 36 | 37 | import java.awt.*; 38 | import java.awt.event.MouseEvent; 39 | 40 | public class GEventCreateElement extends GAbstractEvent { 41 | 42 | public GEventCreateElement(GView view) { 43 | super(view); 44 | } 45 | 46 | public void mousePressed(MouseEvent e, Point mousePosition) { 47 | GElement selectedElement = delegate.eventQueryElementAtPoint(mousePosition); 48 | 49 | if(selectedElement == null) { 50 | if(e.getClickCount() == 1) 51 | delegate.eventCreateElement(mousePosition, false); 52 | else 53 | delegate.eventCreateElement(mousePosition, true); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GEventDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.object.GElement; 35 | 36 | import java.awt.*; 37 | 38 | public interface GEventDelegate { 39 | public void eventChangeDone(); 40 | public void eventShouldRepaint(); 41 | 42 | public GElement eventQueryElementAtPoint(Point p); 43 | public GElement eventQueryRootElement(); 44 | 45 | public void eventSouldSelectAllElements(boolean flag); 46 | public void eventMoveSelectedElements(int dx, int dy); 47 | public void eventSelectElementsInRect(int x, int y, int dx, int dy); 48 | 49 | public void eventCreateElement(Point point, boolean doubleclick); 50 | public void eventEditElement(GElement e); 51 | 52 | public boolean eventCanCreateLink(); 53 | public double eventLinkFlateness(); 54 | public void eventCreateLink(GElement source, String sourceAnchorKey, GElement target, String targetAnchorKey, int shape, Point p); 55 | 56 | public void eventAddFocusedElement(GElement element); 57 | public void eventRemoveFocusedElement(GElement element); 58 | public boolean eventIsSelectedElement(GElement element); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GEventDragRootElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.GView; 35 | import edu.usfca.xj.appkit.gview.base.Vector2D; 36 | 37 | import java.awt.*; 38 | import java.awt.event.InputEvent; 39 | import java.awt.event.MouseEvent; 40 | 41 | public class GEventDragRootElement extends GAbstractEvent { 42 | 43 | private boolean dragging = false; 44 | 45 | public GEventDragRootElement(GView view) { 46 | super(view); 47 | } 48 | 49 | public void mousePressed(MouseEvent e, Point mousePosition) { 50 | if(hasExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE)) 51 | return; 52 | 53 | if(e.getClickCount() != 1) 54 | return; 55 | 56 | int mask = InputEvent.SHIFT_DOWN_MASK + InputEvent.BUTTON1_DOWN_MASK; 57 | if((e.getModifiersEx() & mask) == mask && delegate.eventQueryElementAtPoint(mousePosition) == null) { 58 | addExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE); 59 | delegate.eventQueryRootElement().beginDrag(); 60 | dragging = true; 61 | } 62 | } 63 | 64 | public void mouseReleased(MouseEvent e, Point mousePosition) { 65 | removeExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE); 66 | delegate.eventShouldRepaint(); 67 | dragging = false; 68 | } 69 | 70 | public void mouseDragged(MouseEvent e, Point mousePosition) { 71 | if(dragging) { 72 | delegate.eventQueryRootElement().drag(Vector2D.vector(mousePosition)); 73 | delegate.eventChangeDone(); 74 | delegate.eventShouldRepaint(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GEventEditElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.GView; 35 | import edu.usfca.xj.appkit.gview.object.GElement; 36 | 37 | import java.awt.*; 38 | import java.awt.event.MouseEvent; 39 | 40 | public class GEventEditElement extends GAbstractEvent { 41 | 42 | public GEventEditElement(GView view) { 43 | super(view); 44 | } 45 | 46 | public void mousePressed(MouseEvent e, Point mousePosition) { 47 | GElement selectedElement = delegate.eventQueryElementAtPoint(mousePosition); 48 | if(e.getClickCount() == 2 && selectedElement != null) { 49 | delegate.eventEditElement(selectedElement); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GEventFocusElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.GView; 35 | import edu.usfca.xj.appkit.gview.object.GElement; 36 | 37 | import java.awt.*; 38 | import java.awt.event.MouseEvent; 39 | 40 | public class GEventFocusElement extends GAbstractEvent { 41 | 42 | public GElement focusedElement = null; 43 | 44 | public GEventFocusElement(GView view) { 45 | super(view); 46 | } 47 | 48 | public void mouseDragged(MouseEvent e, Point mousePosition) { 49 | focusOnElement(delegate.eventQueryElementAtPoint(mousePosition)); 50 | } 51 | 52 | public void mouseMoved(MouseEvent e, Point mousePosition) { 53 | focusOnElement(delegate.eventQueryElementAtPoint(mousePosition)); 54 | } 55 | 56 | public void setFocusedElement(GElement element) { 57 | if(focusedElement != null) { 58 | focusedElement.setFocused(false); 59 | delegate.eventRemoveFocusedElement(focusedElement); 60 | delegate.eventShouldRepaint(); 61 | } 62 | focusedElement = element; 63 | if(focusedElement != null) { 64 | focusedElement.setFocused(true); 65 | delegate.eventAddFocusedElement(focusedElement); 66 | delegate.eventShouldRepaint(); 67 | } 68 | } 69 | 70 | public void focusOnElement(GElement element) { 71 | if(element != null) { 72 | if(manager.canFocusOnElement(element)) 73 | setFocusedElement(element); 74 | } else 75 | setFocusedElement(null); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/event/GEventModifyLinkElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.event; 33 | 34 | import edu.usfca.xj.appkit.gview.GView; 35 | import edu.usfca.xj.appkit.gview.object.GElement; 36 | import edu.usfca.xj.appkit.gview.object.GLink; 37 | 38 | import java.awt.*; 39 | import java.awt.event.MouseEvent; 40 | 41 | public class GEventModifyLinkElement extends GAbstractEvent { 42 | 43 | public GElement selectedLink = null; 44 | 45 | public GEventModifyLinkElement(GView view) { 46 | super(view); 47 | } 48 | 49 | public void mousePressed(MouseEvent e, Point mousePosition) { 50 | if(hasExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE)) 51 | return; 52 | 53 | if(e.getClickCount() != 1) 54 | return; 55 | 56 | selectedLink = delegate.eventQueryElementAtPoint(mousePosition); 57 | 58 | if(selectedLink == null || !(selectedLink instanceof GLink)) { 59 | selectedLink = null; 60 | return; 61 | } 62 | 63 | addExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE); 64 | } 65 | 66 | public void mouseReleased(MouseEvent e, Point mousePosition) { 67 | removeExclusiveValue(GEventManager.EXCLUSIVE_DRAG_VALUE); 68 | selectedLink = null; 69 | } 70 | 71 | public void mouseDragged(MouseEvent e, Point mousePosition) { 72 | if(selectedLink == null) 73 | return; 74 | 75 | ((GLink)selectedLink).setMousePosition(mousePosition); 76 | 77 | delegate.eventChangeDone(); 78 | delegate.eventShouldRepaint(); 79 | } 80 | 81 | public boolean shouldFocusOnElement(GElement element) { 82 | return selectedLink == null; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/object/GElementArrow.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.object; 33 | 34 | import edu.usfca.xj.appkit.gview.base.Rect; 35 | import edu.usfca.xj.appkit.gview.base.Vector2D; 36 | import edu.usfca.xj.appkit.gview.shape.SArrow; 37 | import edu.usfca.xj.foundation.XJXMLSerializable; 38 | 39 | import java.awt.*; 40 | 41 | public class GElementArrow extends GElement implements XJXMLSerializable { 42 | 43 | protected SArrow arrow; 44 | protected Vector2D target; 45 | 46 | public GElementArrow() { 47 | setArrow(new SArrow()); 48 | } 49 | 50 | public void setArrow(SArrow arrow) { 51 | this.arrow = arrow; 52 | } 53 | 54 | public SArrow getArrow() { 55 | return arrow; 56 | } 57 | 58 | public void setArrowLength(double length) { 59 | arrow.setLength(length); 60 | } 61 | 62 | public void setSource(double x, double y) { 63 | super.setPosition(x, y); 64 | } 65 | 66 | public void setTarget(double x, double y) { 67 | arrow.setAnchor(x, y); 68 | 69 | target = new Vector2D(x, y); 70 | Vector2D direction = getPosition().sub(target); 71 | arrow.setDirection(direction); 72 | } 73 | 74 | public void setTarget(Vector2D target) { 75 | this.target = target; 76 | } 77 | 78 | public Vector2D getTarget() { 79 | return target; 80 | } 81 | 82 | public void move(double dx, double dy) { 83 | super.move(dx, dy); 84 | target.shift(dx, dy); 85 | arrow.getAnchor().shift(dx, dy); 86 | } 87 | 88 | public Rect getFrame() { 89 | return new Rect(getPosition(), target, 2, 2); 90 | } 91 | 92 | public boolean isInside(Point p) { 93 | return getFrame().contains(p); 94 | } 95 | 96 | public void draw(Graphics2D g) { 97 | g.setColor(color); 98 | drawShape(g); 99 | } 100 | 101 | public void drawShape(Graphics2D g) { 102 | super.drawShape(g); 103 | 104 | arrow.draw(g); 105 | g.drawLine((int)getPositionX(), (int)getPositionY(), (int)target.x, (int)target.y); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/object/GElementLabel.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.object; 33 | 34 | import edu.usfca.xj.appkit.gview.base.Rect; 35 | import edu.usfca.xj.appkit.gview.shape.SLabel; 36 | import edu.usfca.xj.foundation.XJXMLSerializable; 37 | 38 | import java.awt.*; 39 | 40 | public class GElementLabel extends GElement implements XJXMLSerializable { 41 | 42 | protected transient Graphics2D g = null; 43 | 44 | public GElementLabel() { 45 | super(); 46 | } 47 | 48 | public Rect getFrame() { 49 | return SLabel.getFrame(getLabel(), getPositionX(), getPositionY(), g); 50 | } 51 | 52 | public boolean isInside(Point p) { 53 | return getFrame().contains(p); 54 | } 55 | 56 | public void draw(Graphics2D g) { 57 | super.draw(g); 58 | 59 | this.g = g; 60 | if(labelVisible) { 61 | g.setColor(labelColor); 62 | SLabel.drawCenteredString(getLabel(), (int)getPositionX(), (int)getPositionY(), g); 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/shape/SArrow.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.shape; 33 | 34 | import edu.usfca.xj.appkit.gview.base.Vector2D; 35 | import edu.usfca.xj.foundation.XJXMLSerializable; 36 | 37 | import java.awt.*; 38 | 39 | public class SArrow implements XJXMLSerializable { 40 | 41 | protected Vector2D anchor = null; 42 | protected Vector2D direction = null; 43 | 44 | protected double length = 10; 45 | protected double angle = 45; 46 | 47 | public SArrow() { 48 | 49 | } 50 | 51 | public void setAnchor(double x, double y) { 52 | anchor = new Vector2D(x, y); 53 | } 54 | 55 | public void setAnchor(Vector2D anchor) { 56 | this.anchor = anchor; 57 | } 58 | 59 | public Vector2D getAnchor() { 60 | return anchor; 61 | } 62 | 63 | public void setDirection(Vector2D direction) { 64 | if(direction != null) 65 | this.direction = direction.copy(); 66 | else 67 | this.direction = null; 68 | } 69 | 70 | public Vector2D getDirection() { 71 | return direction; 72 | } 73 | 74 | public void setLength(double length) { 75 | this.length = length; 76 | } 77 | 78 | public double getLength() { 79 | return length; 80 | } 81 | 82 | public void setAngle(double angle) { 83 | this.angle = angle; 84 | } 85 | 86 | public double getAngle() { 87 | return angle; 88 | } 89 | 90 | public void draw(Graphics g) { 91 | if(direction == null || anchor == null) 92 | return; 93 | 94 | Vector2D v = direction.copy(); 95 | v.setLength(length); 96 | 97 | v.rotate(angle*0.5); 98 | g.drawLine((int)anchor.getX(), (int)anchor.getY(), (int)(anchor.getX()+v.getX()), (int)(anchor.getY()+v.getY())); 99 | 100 | v.rotate(-angle); 101 | g.drawLine((int)anchor.getX(), (int)anchor.getY(), (int)(anchor.getX()+v.getX()), (int)(anchor.getY()+v.getY())); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/timer/GTimerDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.timer; 33 | 34 | public interface GTimerDelegate { 35 | public void timerFired(GTimer timer); 36 | } 37 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/utils/GAlphaVariator.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.utils; 33 | 34 | public class GAlphaVariator { 35 | 36 | private int alphaColorValueDir = 1; 37 | private float alphaColorValue = 0; 38 | 39 | public float getAlphaValue() { 40 | return alphaColorValue; 41 | } 42 | 43 | public void run() { 44 | alphaColorValue += alphaColorValueDir*0.1f; 45 | if(alphaColorValue > 1) { 46 | alphaColorValue = 1; 47 | alphaColorValueDir = -alphaColorValueDir; 48 | } else if(alphaColorValue < 0) { 49 | alphaColorValue = 0; 50 | alphaColorValueDir = -alphaColorValueDir; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/gview/utils/GMagnetic.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.gview.utils; 33 | 34 | import edu.usfca.xj.appkit.gview.base.Vector2D; 35 | 36 | import java.awt.*; 37 | 38 | public class GMagnetic { 39 | 40 | public static final int HORIZONTAL = 0; 41 | public static final int VERTICAL = 1; 42 | 43 | private int kind = HORIZONTAL; 44 | private double factor = 0; 45 | private boolean visible = false; 46 | 47 | public static GMagnetic createHorizontal(double factor) { 48 | GMagnetic m = new GMagnetic(); 49 | m.kind = HORIZONTAL; 50 | m.factor = factor; 51 | return m; 52 | } 53 | 54 | public static GMagnetic createVertical(double factor) { 55 | GMagnetic m = new GMagnetic(); 56 | m.kind = VERTICAL; 57 | m.factor = factor; 58 | return m; 59 | } 60 | 61 | public void setVisible(boolean flag) { 62 | this.visible = flag; 63 | } 64 | 65 | public boolean isVisible() { 66 | return visible; 67 | } 68 | 69 | public void showAndAjust(Vector2D position, Dimension realSize) { 70 | setVisible(false); 71 | 72 | if(kind == HORIZONTAL) { 73 | if(Math.abs(position.y-realSize.height*factor)<5) { 74 | position.y = realSize.height*factor; 75 | setVisible(true); 76 | } 77 | } else { 78 | if(Math.abs(position.x-realSize.width*factor)<5) { 79 | position.x = realSize.width*factor; 80 | setVisible(true); 81 | } 82 | } 83 | } 84 | 85 | public void draw(Graphics2D g2d, Dimension realSize) { 86 | int middleV = (int)(realSize.height*factor); 87 | int middleH = (int)(realSize.width*factor); 88 | 89 | if(kind == HORIZONTAL) { 90 | g2d.drawLine(0, middleV, realSize.width, middleV); 91 | } else { 92 | g2d.drawLine(middleH, 0, middleH, realSize.height); 93 | } 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/menu/XJMenuBarCustomizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.menu; 33 | 34 | public interface XJMenuBarCustomizer { 35 | public void customizeFileMenu(XJMenu menu); 36 | public void customizeEditMenu(XJMenu menu); 37 | public void customizeWindowMenu(XJMenu menu); 38 | public void customizeHelpMenu(XJMenu menu); 39 | public void customizeMenuBar(XJMainMenuBar menubar); 40 | } 41 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/menu/XJMenuBarDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.menu; 33 | 34 | public interface XJMenuBarDelegate { 35 | public void menuItemState(XJMenuItem item); 36 | public void handleMenuEvent(XJMenu menu, XJMenuItem item); 37 | public void handleMenuSelected(XJMenu menu); 38 | } 39 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/menu/XJMenuItemCheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.menu; 33 | 34 | import javax.swing.*; 35 | 36 | public class XJMenuItemCheck extends XJMenuItem { 37 | 38 | public XJMenuItemCheck() { 39 | super(); 40 | } 41 | 42 | public XJMenuItemCheck(String title, int tag, XJMenuItemDelegate delegate, boolean checked) { 43 | super(title, tag, delegate); 44 | this.setSelected(checked); 45 | } 46 | 47 | public void init() { 48 | jMenuItem = new JCheckBoxMenuItem(); 49 | jMenuItem.addActionListener(new MenuActionListener()); 50 | } 51 | 52 | public void setTitle(String title) { 53 | jMenuItem.setText(title); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/menu/XJMenuItemDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.menu; 33 | 34 | public interface XJMenuItemDelegate { 35 | public void handleMenuEvent(XJMenu menu, XJMenuItem item); 36 | } 37 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/menu/XJMenuItemSeparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.menu; 33 | 34 | public class XJMenuItemSeparator extends XJMenuItem { 35 | } 36 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/appkit/swing/XJLookAndFeel.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.appkit.swing; 33 | 34 | import javax.swing.*; 35 | import java.awt.*; 36 | 37 | public class XJLookAndFeel { 38 | 39 | public static String applyLookAndFeel(String name) { 40 | String className = getLookAndFeelClassName(name); 41 | if(className == null) { 42 | System.err.println("No LAF class name for name '"+name+"', using default LAF."); 43 | className = getLookAndFeelClassName(null); 44 | } 45 | 46 | try { 47 | UIManager.setLookAndFeel(className); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | 52 | Frame[] frame = Frame.getFrames(); 53 | for(int i=0; i=0; i--) { 60 | XJNotificationObserver candidate = (XJNotificationObserver) obs.get(i); 61 | if(candidate.equals(observer)) { 62 | obs.remove(i); 63 | } 64 | } 65 | } 66 | } 67 | 68 | public void postNotification(Object source, String notifName) { 69 | List obs = (List)observers.get(notifName); 70 | if(obs == null) 71 | return; 72 | 73 | for (Iterator iterator = obs.iterator(); iterator.hasNext();) { 74 | XJNotificationObserver observer = (XJNotificationObserver) iterator.next(); 75 | observer.notificationFire(source, notifName); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/foundation/notification/XJNotificationObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.foundation.notification; 33 | 34 | public interface XJNotificationObserver { 35 | public void notificationFire(Object source, String name); 36 | } 37 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/foundation/timer/XJScheduledTimer.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.foundation.timer; 33 | 34 | public class XJScheduledTimer { 35 | 36 | protected XJScheduledTimerDelegate delegate; 37 | protected long numberOfMinutes; 38 | protected long remainingMinutes; 39 | protected boolean scheduleAtStartup; 40 | 41 | public XJScheduledTimer(XJScheduledTimerDelegate delegate, long minutes, boolean scheduleAtStartup) { 42 | this.delegate = delegate; 43 | this.numberOfMinutes = minutes; 44 | this.scheduleAtStartup = scheduleAtStartup; 45 | 46 | remainingMinutes = numberOfMinutes; 47 | } 48 | 49 | public XJScheduledTimerDelegate getDelegate() { 50 | return delegate; 51 | } 52 | 53 | public void fire(boolean startup, long elapsedMinutes) { 54 | if(scheduleAtStartup && startup) { 55 | delegate.scheduledTimerFired(true); 56 | return; 57 | } else if(!scheduleAtStartup && startup) 58 | return; 59 | 60 | remainingMinutes -= elapsedMinutes; 61 | if(remainingMinutes <= 0) { 62 | delegate.scheduledTimerFired(false); 63 | remainingMinutes = numberOfMinutes; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/foundation/timer/XJScheduledTimerDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | [The "BSD licence"] 4 | Copyright (c) 2005 Jean Bovet 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 3. The name of the author may not be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | package edu.usfca.xj.foundation.timer; 33 | 34 | public interface XJScheduledTimerDelegate { 35 | public void scheduledTimerFired(boolean startup); 36 | } 37 | -------------------------------------------------------------------------------- /src/edu/usfca/xj/properties/strings.properties: -------------------------------------------------------------------------------- 1 | 2 | # XJMainMenuBar 3 | 4 | File = File 5 | New = New 6 | Open = Open... 7 | Load = Load... 8 | Close = Close 9 | Save = Save 10 | SaveAs = Save As... 11 | Quit = Quit 12 | 13 | Preferences = Preferences 14 | 15 | OpenRecent = Open Recent 16 | ClearMenu = Clear Menu 17 | NoWindows = No windows 18 | 19 | Edit = Edit 20 | Undo = Undo 21 | Redo = Redo 22 | Cut = Cut 23 | Copy = Copy 24 | Paste = Paste 25 | SelectAll = Select All 26 | 27 | Window = Window 28 | Help = Help 29 | About = About 30 | 31 | # XJDocument 32 | 33 | DocUntitled = Untitled 34 | DocLoad = Load (into same document) 35 | DocSaveChanges = Do you want to save the changes you made in the document \"{0}\" ? 36 | 37 | DocCloseTitle = Close Document 38 | DocCloseMessage = Do you want to save the changes you made in the document \"{0}\" ? 39 | 40 | DocError = Error 41 | DocLoadError = An error has occurred while opening a document: 42 | DocSaveError = An error has occurred while saving a document: 43 | DocLoadExists = Cannot load the file because another document associated with this file is already opened 44 | 45 | # XJApplication 46 | 47 | AppNewDocTitle = New Document 48 | AppNewDocMessage = Choose which document to create: 49 | 50 | AppNewDocErrTitle = Cannot create the document 51 | AppNewDocErrMessage = No Java-class specified 52 | 53 | AppNewDocError = Cannot create the document 54 | 55 | AppUntitled = Untitled --------------------------------------------------------------------------------