Package wprover
Class GExpert
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- javax.swing.JFrame
-
- wprover.GExpert
-
- All Implemented Interfaces:
java.awt.dnd.DropTargetListener,java.awt.event.ActionListener,java.awt.event.KeyListener,java.awt.event.WindowListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,javax.swing.RootPaneContainer,javax.swing.WindowConstants
public class GExpert extends javax.swing.JFrame implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.dnd.DropTargetListener, java.awt.event.WindowListenerGExpert is the main class for the GEXPERT application. It initializes the application, sets up the GUI, and handles user interactions. It also manages the language settings and file operations.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
-
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String_commandstatic java.util.ArrayList<java.lang.String>commandlineCommandstatic intcommandLineRequestsPerformedstatic java.util.ArrayList<java.lang.Object>commandlineSrcstatic ConsconclusionCPropertycpwprover.DPaneldDrawTextProcessdpstatic longHotKeyTimerstatic org.xnap.commons.i18n.I18ni18nstatic java.lang.StringlanListTreelpjavax.swing.JScrollPanescroll-
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description GExpert()Constructs a new GExpert instance and initializes the application if it is running as an application.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)Handles action events by sending the action command and source to the sendAction method.javax.swing.JMenuItemaddAMenu(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, int ne, java.awt.event.ActionListener listener)Adds a menu item to the specified menu bar with the given name, tooltip, mnemonic, and action listener.javax.swing.JMenuItemaddAMenu(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, java.awt.event.ActionListener listener)Adds a menu item to the specified menu bar with the given name, tooltip, and action listener.protected voidaddButtons(javax.swing.JToolBar toolBar)Adds primary action buttons to the provided tool bar.voidaddButtonToDrawGroup(javax.swing.JToggleButton b)Adds a button to the draw group.voidaddImageToItem(javax.swing.JMenu item)Adds a blank image icon to the specified menu.voidaddImageToItem(javax.swing.JMenuItem item)Adds a blank image icon to the specified menu item.voidaddImageToItem(javax.swing.JMenuItem item, java.lang.String name)Adds an image icon to the specified menu item with the given name.voidaddMenueToolBar()Initializes and adds the menu and tool bar(s) to the application frame.javax.swing.JRadioButtonMenuItemaddRadioButtonMenuItem(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, java.awt.event.ActionListener listener)Creates a JRadioButtonMenuItem with the specified name, tooltip, and action listener.javax.swing.JRadioButtonMenuItemaddRadioButtonMenuItem(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, java.awt.event.ActionListener listener, java.lang.String command)Creates a JRadioButtonMenuItem with the specified name, tooltip, action listener, and command.javax.swing.JRadioButtonMenuItemaddRadioButtonMenuItem(javax.swing.JMenu bar, java.lang.String name, java.lang.String text, java.lang.String tooltip, java.awt.event.ActionListener listener)Creates a JRadioButtonMenuItem with the specified name, custom text, tooltip, and action listener.protected voidaddRightButtons(javax.swing.JToolBar toolBar)Adds right-side buttons to the provided tool bar.voidaddSplitListener()Adds a component listener to the drawing panel to handle resizing and visibility changes.voidcenterDialog(javax.swing.JDialog dlg)Centers the given dialog relative to the main frame.intClear()Clears the current diagram and resets the application state.voidcloseAllDialogs()Closes all open dialogs in the application.protected static javax.swing.ImageIconcreateImageIcon(java.lang.String path)Create an ImageIcon from the path.voidcreateTipLabel()Creates and initializes the tip label.voiddragEnter(java.awt.dnd.DropTargetDragEvent dtde)voiddragExit(java.awt.dnd.DropTargetEvent dte)voiddragOver(java.awt.dnd.DropTargetDragEvent dtde)voiddrop(java.awt.dnd.DropTargetDropEvent dtde)This method is called when the user drops a file on the window.voiddropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)booleanget_User_Overwrite_Option(java.lang.String name)Prompts the user to confirm overwriting an existing file.AnimatePanelgetAnimateDialog()Returns the AnimatePanel object, initializing it if necessary.java.awt.image.BufferedImagegetBufferedImage(java.awt.Rectangle rc)Returns a buffered image of the drawing area bounded by the specified rectangle.java.awt.image.BufferedImagegetBufferedImage2(java.awt.Rectangle rc)Returns a buffered image of the content pane bounded by the specified rectangle.ConcDialoggetConcDialog()Returns the conclusion dialog, initializing it if necessary.javax.swing.JComponentgetContent()Returns the main content pane of the application.java.awt.FontgetDefaultFont()Returns the default font of the application.DialogPropertygetDialogProperty()Returns the dialog property, initializing it if necessary.CDialogProvegetDialogProve()Returns the prove dialog, initializing it if necessary.javax.swing.JFileChoosergetFileChooser(boolean importGgb)Returns a file chooser, initializing it if necessary.static java.lang.StringgetFileSeparator()Returns the file separator.java.awt.FramegetFrame()Returns the Frame object of the application.LanguagegetLan()Returns the current language settings.static java.lang.StringgetLanguage(java.lang.String s1)Returns the translated string for the given key.static java.lang.StringgetLanguageTip(java.lang.String s1)Returns the tooltip text for the given key.MProveInputPanelgetMannalInputToolBar()Returns the manual input toolbar.PanelProvegetpprove()Returns the PanelProve object.intgetProveStatus()Returns the prove status.static java.net.URLgetResourceURL(java.lang.String path)Get the resource URL from the path.RuleDialoggetRuleDialog(int n)Returns the RuleDialog object for the specified rule, initializing it if necessary.SelectDialoggetSelectDialog()Returns the select dialog, initializing it if necessary.CStyleDialoggetStyleDialog()Returns the style dialog.static java.lang.StringgetTranslationViaGettext(java.lang.String s)Returns the translated string for the given key using gettext.static java.lang.StringgetTranslationViaGettext(java.lang.String s, java.lang.String... p)Returns the translated string for the given key using gettext with parameters.UndoEditDialoggetUndoEditDialog()Returns the undo edit dialog, initializing it if necessary.static java.lang.StringgetUserDir()Returns the user directory.static java.lang.StringgetUserHome()Returns the user home directory.booleanhasAFrame()Checks if the animate frame is present.booleanhasMannualInputBar()Checks if the manual input bar is present.voidinit()Initializes the GExpert application, setting up the GUI components, loading preferences, language settings, and rules.voidinitAttribute()Initializes the attributes of the application, setting the font if the language is not English.voidinitKeyMap()Initializes the key mapping by registering a KeyEventPostProcessor.booleanisconcVisible()Checks if the conclusion dialog is visible.booleanisDialogProveVisible()Checks if the prove dialog is visible.booleanisPPanelVisible()Checks if the panel is visible.static booleanisRunningFromJar()Checks if the application is running in a JAR file (including CheerpJ web environment).static booleanisRunningInCheerpJ()Checks if the application is running in a CheerpJ web environment.voidkeyPressed(java.awt.event.KeyEvent e)Handles key pressed events.voidkeyReleased(java.awt.event.KeyEvent e)Handles key released events.voidkeyTyped(java.awt.event.KeyEvent e)Handles key typed events.voidloadCursor()Loads the cursor for the application.voidloadLanguage()Loads the language settings for the application and sets up internationalization.voidloadPreference()Loads the user preferences from the configuration file.voidloadRules()Loads the rules for the GExpert application.static voidmain(java.lang.String[] args)Main entry point of the application.protected javax.swing.JToggleButtonmakeAButton(java.lang.String imageName, java.lang.String actionCommand, java.lang.String toolTipText, java.lang.String altText)Creates a toggle button with the specified image, action command, tooltip text, and alternate text.protected javax.swing.JToggleButtonmakeAButton(java.lang.String imageName, java.lang.String actionCommand, java.lang.String toolTipText, java.lang.String altText, boolean t)Creates a toggle button with the specified image, action command, tooltip text, alternate text, and an optional action listener.protected javax.swing.JToggleButtonmakeAButtonWith2ICon(java.lang.String imageName, java.lang.String imageNameSelected, java.lang.String actionCommand, java.lang.String toolTipText, java.lang.String altText)Creates a toggle button with two icons, one for the default state and one for the selected state.booleanneed_save()Checks if there are any unsaved changes.voidonKeyCancel()Cancels the current action triggered by key events.booleanopenAFile(java.io.File file)Opens and loads a project file.booleanopenResourceFile(java.lang.String resourcePath)Opens and loads a project file from a resource path.static voidopenURL(java.lang.String url)Opens the specified URL in the system's default web browser or handles it appropriately for the current environment (desktop or web/CheerpJ).static voidperformCommandLineRequests(GExpert exp, boolean breakOnProve)Perform command line requests.voidreloadLP()Reloads the list of points if the list panel and undo dialog are visible.voidresetAllButtonStatus()This method is used to reset all button status.voidrestorScroll()This method is used to restore the scroll.booleansaveAFile(boolean n)Saves the current file.voidsaveAFile(java.lang.String path)Saves the project to a file at the specified path.voidsaveAsGIF()Saves the current animation as a GIF.voidsaveAsImage()Saves the current view as an image file.voidsaveAsPDF()Saves the current view as a PDF file.booleansaveBeforeExit()Prompts the user to save any unsaved changes before exiting the application.voidsaveProofAsGIF()Saves the proof as a GIF image.voidselectAPoint(CPoint p)Selects a point in the number check dialog if it is visible.voidsendAction(java.lang.String command, java.lang.Object src)Processes an action command based on the provided command string and source.voidsetActionMove()Sets the action to "Move" and selects the move button.voidsetActionPool(int a)Configures the action pool based on the specified pool type.voidsetActionSelect()Sets the action to "Select" and selects the select button.voidsetActionTip(java.lang.String name, java.lang.String tip)This method is used to set the text of the label.voidsetBKState()Sets the enabled state of the undo and redo buttons based on the sizes of the undo and redo lists.voidsetDrawCursor(int t)Sets the cursor to the specified predefined cursor type.voidsetLabelText2(java.lang.String s)This method is used to set the text of the label2.voidsetLocation(int x, int y)Sets the location of the frame.static voidsetLookAndFeel()voidsetTextLabel2(java.lang.String s)This method is used to set the text of the label2.voidsetTextLabel2(java.lang.String s, int n)This method is used to set the text of the label2.voidsetTipText(java.lang.String text)This method is used to set the text of the tip.static voidsetUIFont(javax.swing.plaf.FontUIResource f)Sets the default UI font for all components.voidshowAnimatePane()Shows the animate pane.voidshowNumDialog()Shows the number check dialog if there are points to check.voidshowppanel(boolean t)Shows or hides the panel.voidshowProveBar(boolean show)Shows or hides the prove bar.voidshowRulePanel(java.lang.String s, int x, int y)Shows the rule panel at the specified location.voidshowStyleDialog()Shows the style dialog.voidstart()Starts or initializes the component.voidstop()Stops or cleans up the component.voidstopTimer()This method is used to stop the timer.voidswitchProveBarVisibility(boolean r)Switches the visibility of the prove bar.voidupdateActionPool(int n)Updates the action pool using the currently selected list of objects.voidupdateTitle()This method is used to update the title of the window.voidviewElementsAuto(CClass c)Automatically sets the panel type for the given class.voidwindowActivated(java.awt.event.WindowEvent e)voidwindowClosed(java.awt.event.WindowEvent e)voidwindowClosing(java.awt.event.WindowEvent e)This method is called when the user closes the window.voidwindowDeactivated(java.awt.event.WindowEvent e)voidwindowDeiconified(java.awt.event.WindowEvent e)voidwindowIconified(java.awt.event.WindowEvent e)voidwindowOpened(java.awt.event.WindowEvent e)-
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
d
public wprover.DPanel d
-
dp
public DrawTextProcess dp
-
cp
public CProperty cp
-
lp
public ListTree lp
-
scroll
public javax.swing.JScrollPane scroll
-
_command
public java.lang.String _command
-
lan
public static java.lang.String lan
-
i18n
public static org.xnap.commons.i18n.I18n i18n
-
conclusion
public static Cons conclusion
-
commandlineCommand
public static java.util.ArrayList<java.lang.String> commandlineCommand
-
commandlineSrc
public static java.util.ArrayList<java.lang.Object> commandlineSrc
-
commandLineRequestsPerformed
public static int commandLineRequestsPerformed
-
HotKeyTimer
public static long HotKeyTimer
-
-
Method Detail
-
init
public void init()
Initializes the GExpert application, setting up the GUI components, loading preferences, language settings, and rules. It also initializes various attributes and sets up the main content pane.
-
loadRules
public void loadRules()
Loads the rules for the GExpert application.
-
getContent
public javax.swing.JComponent getContent()
Returns the main content pane of the application.- Returns:
- the main content pane
-
addSplitListener
public void addSplitListener()
Adds a component listener to the drawing panel to handle resizing and visibility changes.
-
loadPreference
public void loadPreference()
Loads the user preferences from the configuration file.
-
loadLanguage
public void loadLanguage()
Loads the language settings for the application and sets up internationalization.
-
initAttribute
public void initAttribute()
Initializes the attributes of the application, setting the font if the language is not English.
-
getDefaultFont
public java.awt.Font getDefaultFont()
Returns the default font of the application.- Returns:
- the default Font object, or null if the language is not set
-
getFrame
public java.awt.Frame getFrame()
Returns the Frame object of the application.- Returns:
- the Frame object, or null if no Frame is found
-
loadCursor
public void loadCursor()
Loads the cursor for the application.
-
isPPanelVisible
public boolean isPPanelVisible()
Checks if the panel is visible.- Returns:
- true if the panel is visible, false otherwise
-
showppanel
public void showppanel(boolean t)
Shows or hides the panel.- Parameters:
t- if true, hides the panel; if false, shows the panel
-
showRulePanel
public void showRulePanel(java.lang.String s, int x, int y)Shows the rule panel at the specified location.- Parameters:
s- the rule to be shownx- the x-coordinate of the locationy- the y-coordinate of the location
-
getpprove
public PanelProve getpprove()
Returns the PanelProve object.- Returns:
- the PanelProve object
-
hasAFrame
public boolean hasAFrame()
Checks if the animate frame is present.- Returns:
- true if the animate frame is present, false otherwise
-
getAnimateDialog
public AnimatePanel getAnimateDialog()
Returns the AnimatePanel object, initializing it if necessary.- Returns:
- the AnimatePanel object
-
showAnimatePane
public void showAnimatePane()
Shows the animate pane.
-
getRuleDialog
public RuleDialog getRuleDialog(int n)
Returns the RuleDialog object for the specified rule, initializing it if necessary.- Parameters:
n- the rule number- Returns:
- the RuleDialog object
-
viewElementsAuto
public void viewElementsAuto(CClass c)
Automatically sets the panel type for the given class.- Parameters:
c- the class for which the panel type is to be set
-
getDialogProperty
public DialogProperty getDialogProperty()
Returns the dialog property, initializing it if necessary.- Returns:
- the dialog property
-
centerDialog
public void centerDialog(javax.swing.JDialog dlg)
Centers the given dialog relative to the main frame.- Parameters:
dlg- the dialog to be centered
-
getSelectDialog
public SelectDialog getSelectDialog()
Returns the select dialog, initializing it if necessary.- Returns:
- the select dialog
-
isconcVisible
public boolean isconcVisible()
Checks if the conclusion dialog is visible.- Returns:
- true if the conclusion dialog is visible, false otherwise
-
getConcDialog
public ConcDialog getConcDialog()
Returns the conclusion dialog, initializing it if necessary.- Returns:
- the conclusion dialog
-
showNumDialog
public void showNumDialog()
Shows the number check dialog if there are points to check.
-
selectAPoint
public void selectAPoint(CPoint p)
Selects a point in the number check dialog if it is visible.- Parameters:
p- the point to be selected
-
getUndoEditDialog
public UndoEditDialog getUndoEditDialog()
Returns the undo edit dialog, initializing it if necessary.- Returns:
- the undo edit dialog
-
isDialogProveVisible
public boolean isDialogProveVisible()
Checks if the prove dialog is visible.- Returns:
- true if the prove dialog is visible, false otherwise
-
getDialogProve
public CDialogProve getDialogProve()
Returns the prove dialog, initializing it if necessary.- Returns:
- the prove dialog
-
getFileChooser
public javax.swing.JFileChooser getFileChooser(boolean importGgb)
Returns a file chooser, initializing it if necessary.- Parameters:
importGgb- if true, sets the file filter to GeoGebra files; otherwise, sets it to GEX files- Returns:
- the file chooser
-
getUserDir
public static java.lang.String getUserDir()
Returns the user directory.- Returns:
- the user directory
-
getUserHome
public static java.lang.String getUserHome()
Returns the user home directory.- Returns:
- the user home directory
-
getFileSeparator
public static java.lang.String getFileSeparator()
Returns the file separator.- Returns:
- the file separator
-
hasMannualInputBar
public boolean hasMannualInputBar()
Checks if the manual input bar is present.- Returns:
- true if the manual input bar is present, false otherwise
-
getProveStatus
public int getProveStatus()
Returns the prove status.- Returns:
- the prove status
-
getStyleDialog
public CStyleDialog getStyleDialog()
Returns the style dialog.- Returns:
- the style dialog
-
getMannalInputToolBar
public MProveInputPanel getMannalInputToolBar()
Returns the manual input toolbar.- Returns:
- the manual input toolbar
-
addButtonToDrawGroup
public void addButtonToDrawGroup(javax.swing.JToggleButton b)
Adds a button to the draw group.- Parameters:
b- the button to be added
-
switchProveBarVisibility
public void switchProveBarVisibility(boolean r)
Switches the visibility of the prove bar.- Parameters:
r- if false, hides the prove bar; if true, shows the prove bar
-
showProveBar
public void showProveBar(boolean show)
Shows or hides the prove bar.- Parameters:
show- if true, shows the prove bar; if false, hides the prove bar
-
showStyleDialog
public void showStyleDialog()
Shows the style dialog.
-
createTipLabel
public void createTipLabel()
Creates and initializes the tip label.
-
setLocation
public void setLocation(int x, int y)Sets the location of the frame.- Overrides:
setLocationin classjava.awt.Window- Parameters:
x- the x-coordinate of the framey- the y-coordinate of the frame
-
addMenueToolBar
public void addMenueToolBar()
Initializes and adds the menu and tool bar(s) to the application frame.This method creates and configures the top toolbar, the right-side toolbar, and the menu bar with all necessary menus and menu items for file operations, examples, construction, constraints, actions, and help. Toolbar buttons and menu items are set up with icons and action listeners.
-
addRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem addRadioButtonMenuItem(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, java.awt.event.ActionListener listener, java.lang.String command)Creates a JRadioButtonMenuItem with the specified name, tooltip, action listener, and command.- Parameters:
bar- the menu to add the item toname- the display name and action command of the menu itemtooltip- the tooltip text to displaylistener- the action listener to register on the menu itemcommand- the specific action command to set- Returns:
- the created JRadioButtonMenuItem
-
addRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem addRadioButtonMenuItem(javax.swing.JMenu bar, java.lang.String name, java.lang.String text, java.lang.String tooltip, java.awt.event.ActionListener listener)Creates a JRadioButtonMenuItem with the specified name, custom text, tooltip, and action listener. The menu item's text is set to its localized value.- Parameters:
bar- the menu to add the item toname- the internal name of the menu item used as its action commandtext- the text to display on the menu item (to be localized)tooltip- the tooltip text to displaylistener- the action listener to register on the menu item- Returns:
- the created JRadioButtonMenuItem with localized text
-
addRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem addRadioButtonMenuItem(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, java.awt.event.ActionListener listener)Creates a JRadioButtonMenuItem with the specified name, tooltip, and action listener. The menu item's text and action command are set based on the provided name. If the tooltip is null, a localized language tip may be used instead.- Parameters:
bar- the menu to add the item toname- the name used as the action command and display text of the menu itemtooltip- the tooltip text to display (or a localized tip if null)listener- the action listener to register on the menu item- Returns:
- the created JRadioButtonMenuItem
-
addAMenu
public javax.swing.JMenuItem addAMenu(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, int ne, java.awt.event.ActionListener listener)Adds a menu item to the specified menu bar with the given name, tooltip, mnemonic, and action listener.- Parameters:
bar- the menu bar to which the menu item will be addedname- the name of the menu itemtooltip- the tooltip text for the menu itemne- the mnemonic for the menu itemlistener- the action listener for the menu item- Returns:
- the created JMenuItem
-
addImageToItem
public void addImageToItem(javax.swing.JMenuItem item)
Adds a blank image icon to the specified menu item.- Parameters:
item- the menu item to which the image icon will be added
-
addImageToItem
public void addImageToItem(javax.swing.JMenu item)
Adds a blank image icon to the specified menu.- Parameters:
item- the menu to which the image icon will be added
-
addImageToItem
public void addImageToItem(javax.swing.JMenuItem item, java.lang.String name)Adds an image icon to the specified menu item with the given name.- Parameters:
item- the menu item to which the image icon will be addedname- the name of the image icon
-
addAMenu
public javax.swing.JMenuItem addAMenu(javax.swing.JMenu bar, java.lang.String name, java.lang.String tooltip, java.awt.event.ActionListener listener)Adds a menu item to the specified menu bar with the given name, tooltip, and action listener.- Parameters:
bar- the menu bar to which the menu item will be addedname- the name of the menu itemtooltip- the tooltip text for the menu itemlistener- the action listener for the menu item- Returns:
- the created JMenuItem
-
getLan
public Language getLan()
Returns the current language settings.- Returns:
- the current Language object
-
getLanguage
public static java.lang.String getLanguage(java.lang.String s1)
Returns the translated string for the given key.- Parameters:
s1- the key to be translated- Returns:
- the translated string
-
getLanguageTip
public static java.lang.String getLanguageTip(java.lang.String s1)
Returns the tooltip text for the given key.- Parameters:
s1- the key to be translated- Returns:
- the translated tooltip text
-
getTranslationViaGettext
public static java.lang.String getTranslationViaGettext(java.lang.String s)
Returns the translated string for the given key using gettext.- Parameters:
s- the key to be translated- Returns:
- the translated string
-
getTranslationViaGettext
public static java.lang.String getTranslationViaGettext(java.lang.String s, java.lang.String... p)Returns the translated string for the given key using gettext with parameters.- Parameters:
s- the key to be translatedp- the parameters for the translation- Returns:
- the translated string
-
setActionMove
public void setActionMove()
Sets the action to "Move" and selects the move button.
-
setActionSelect
public void setActionSelect()
Sets the action to "Select" and selects the select button.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Handles action events by sending the action command and source to the sendAction method.- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener- Parameters:
e- the action event
-
sendAction
public void sendAction(java.lang.String command, java.lang.Object src)Processes an action command based on the provided command string and source.This method interprets the action command triggered by the user and executes the corresponding operation such as saving files, opening dialogs, performing undo/redo actions, updating the UI state, and other application-specific functions.
- Parameters:
command- the action command to be processedsrc- the source object that triggered the command (e.g., JMenuItem, JToggleButton, or File)
-
setBKState
public void setBKState()
Sets the enabled state of the undo and redo buttons based on the sizes of the undo and redo lists.
-
saveBeforeExit
public boolean saveBeforeExit()
Prompts the user to save any unsaved changes before exiting the application.- Returns:
- true if the user chose to save or discard changes, false if the user canceled the operation
-
need_save
public boolean need_save()
Checks if there are any unsaved changes.- Returns:
- true if there are unsaved changes, false otherwise
-
saveAFile
public boolean saveAFile(boolean n)
Saves the current file. If the file does not exist or the user chooses "Save as...", prompts the user to select a file location.- Parameters:
n- if true, prompts the user to select a file location- Returns:
- true if the file was saved successfully, false otherwise
-
Clear
public int Clear()
Clears the current diagram and resets the application state. Prompts the user to save any unsaved changes before clearing.- Returns:
- 0 if the diagram was cleared successfully, 2 if the user canceled the operation
-
closeAllDialogs
public void closeAllDialogs()
Closes all open dialogs in the application.
-
setDrawCursor
public void setDrawCursor(int t)
Sets the cursor to the specified predefined cursor type.- Parameters:
t- the predefined cursor type
-
reloadLP
public void reloadLP()
Reloads the list of points if the list panel and undo dialog are visible.
-
get_User_Overwrite_Option
public boolean get_User_Overwrite_Option(java.lang.String name)
Prompts the user to confirm overwriting an existing file.- Parameters:
name- the name of the file to be overwritten- Returns:
- true if the user chose to overwrite the file, false otherwise
-
saveAFile
public void saveAFile(java.lang.String path) throws java.io.IOExceptionSaves the project to a file at the specified path.- Parameters:
path- the file path to save the project- Throws:
java.io.IOException- if an I/O error occurs during saving
-
saveProofAsGIF
public void saveProofAsGIF()
Saves the proof as a GIF image. Opens dialogs to select the region and file destination, then encodes the proof into a GIF.
-
saveAsGIF
public void saveAsGIF()
Saves the current animation as a GIF. Displays GIF options, captures the animation frames, and writes them to the selected file.
-
saveAsImage
public void saveAsImage()
Saves the current view as an image file. Opens a file chooser to select the output format and destination, then writes the captured image.
-
getBufferedImage
public java.awt.image.BufferedImage getBufferedImage(java.awt.Rectangle rc)
Returns a buffered image of the drawing area bounded by the specified rectangle.- Parameters:
rc- the rectangle defining the area to capture- Returns:
- the buffered image of the drawing area
-
getBufferedImage2
public java.awt.image.BufferedImage getBufferedImage2(java.awt.Rectangle rc)
Returns a buffered image of the content pane bounded by the specified rectangle.- Parameters:
rc- the rectangle defining the area to capture- Returns:
- the buffered image of the content pane
-
openAFile
public boolean openAFile(java.io.File file)
Opens and loads a project file. Adjusts the file extension if necessary, then loads the project data accordingly.- Parameters:
file- the file to open- Returns:
- true if the file was successfully loaded, false otherwise
-
openResourceFile
public boolean openResourceFile(java.lang.String resourcePath)
Opens and loads a project file from a resource path.- Parameters:
resourcePath- the path of the resource to open- Returns:
- true if the file was successfully loaded, false otherwise
-
addRightButtons
protected void addRightButtons(javax.swing.JToolBar toolBar)
Adds right-side buttons to the provided tool bar.- Parameters:
toolBar- the tool bar to which the right-side buttons are added
-
addButtons
protected void addButtons(javax.swing.JToolBar toolBar)
Adds primary action buttons to the provided tool bar.- Parameters:
toolBar- the tool bar to which the primary action buttons are added
-
makeAButton
protected javax.swing.JToggleButton makeAButton(java.lang.String imageName, java.lang.String actionCommand, java.lang.String toolTipText, java.lang.String altText, boolean t)Creates a toggle button with the specified image, action command, tooltip text, alternate text, and an optional action listener.- Parameters:
imageName- the name of the image file (without extension) to be used as the button iconactionCommand- the action command to be set for the buttontoolTipText- the tooltip text to be displayed when the mouse hovers over the buttonaltText- the alternate text to be used if the image cannot be foundt- a boolean indicating whether to add an action listener to the button- Returns:
- the created JToggleButton
-
makeAButton
protected javax.swing.JToggleButton makeAButton(java.lang.String imageName, java.lang.String actionCommand, java.lang.String toolTipText, java.lang.String altText)Creates a toggle button with the specified image, action command, tooltip text, and alternate text.- Parameters:
imageName- the name of the image file (without extension) to be used as the button iconactionCommand- the action command to be set for the buttontoolTipText- the tooltip text to be displayed when the mouse hovers over the buttonaltText- the alternate text to be used if the image cannot be found- Returns:
- the created JToggleButton
-
makeAButtonWith2ICon
protected javax.swing.JToggleButton makeAButtonWith2ICon(java.lang.String imageName, java.lang.String imageNameSelected, java.lang.String actionCommand, java.lang.String toolTipText, java.lang.String altText)Creates a toggle button with two icons, one for the default state and one for the selected state.- Parameters:
imageName- the name of the image file (without extension) to be used as the button icon in the default stateimageNameSelected- the name of the image file (without extension) to be used as the button icon in the selected stateactionCommand- the action command to be set for the buttontoolTipText- the tooltip text to be displayed when the mouse hovers over the buttonaltText- the alternate text to be used if the image cannot be found- Returns:
- the created DActionButton with two status icons
-
resetAllButtonStatus
public void resetAllButtonStatus()
This method is used to reset all button status. It is used to reset all button status when the user drags a file on the window.
-
updateTitle
public void updateTitle()
This method is used to update the title of the window. It is used to update the title of the window when the user drags a file on the window.
-
restorScroll
public void restorScroll()
This method is used to restore the scroll. It is used to restore the scroll when the user drags a file on the window.
-
setActionTip
public void setActionTip(java.lang.String name, java.lang.String tip)This method is used to set the text of the label. It is used to set the text of the label when the user drags a file on the window.
-
setTextLabel2
public void setTextLabel2(java.lang.String s, int n)This method is used to set the text of the label2. It is used to set the text of the label2 when the user drags a file on the window.
-
setLabelText2
public void setLabelText2(java.lang.String s)
This method is used to set the text of the label2. It is used to set the text of the label2 when the user drags a file on the window.
-
stopTimer
public void stopTimer()
This method is used to stop the timer. It is used to stop the timer when the user drags a file on the window.
-
setTextLabel2
public void setTextLabel2(java.lang.String s)
This method is used to set the text of the label2. It is used to set the text of the label2 when the user drags a file on the window.
-
setTipText
public void setTipText(java.lang.String text)
This method is used to set the text of the tip. It is used to set the text of the tip when the user drags a file on the window.
-
dragEnter
public void dragEnter(java.awt.dnd.DropTargetDragEvent dtde)
- Specified by:
dragEnterin interfacejava.awt.dnd.DropTargetListener
-
dragExit
public void dragExit(java.awt.dnd.DropTargetEvent dte)
- Specified by:
dragExitin interfacejava.awt.dnd.DropTargetListener
-
dragOver
public void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
- Specified by:
dragOverin interfacejava.awt.dnd.DropTargetListener
-
dropActionChanged
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent dtde)
- Specified by:
dropActionChangedin interfacejava.awt.dnd.DropTargetListener
-
drop
public void drop(java.awt.dnd.DropTargetDropEvent dtde)
This method is called when the user drops a file on the window. It accepts the drop and adds the file to the text area.- Specified by:
dropin interfacejava.awt.dnd.DropTargetListener
-
windowOpened
public void windowOpened(java.awt.event.WindowEvent e)
- Specified by:
windowOpenedin interfacejava.awt.event.WindowListener
-
windowClosing
public void windowClosing(java.awt.event.WindowEvent e)
This method is called when the user closes the window. It asks the user if he wants to save the file before quitting.- Specified by:
windowClosingin interfacejava.awt.event.WindowListener
-
windowClosed
public void windowClosed(java.awt.event.WindowEvent e)
- Specified by:
windowClosedin interfacejava.awt.event.WindowListener
-
windowIconified
public void windowIconified(java.awt.event.WindowEvent e)
- Specified by:
windowIconifiedin interfacejava.awt.event.WindowListener
-
windowDeiconified
public void windowDeiconified(java.awt.event.WindowEvent e)
- Specified by:
windowDeiconifiedin interfacejava.awt.event.WindowListener
-
windowActivated
public void windowActivated(java.awt.event.WindowEvent e)
- Specified by:
windowActivatedin interfacejava.awt.event.WindowListener
-
windowDeactivated
public void windowDeactivated(java.awt.event.WindowEvent e)
- Specified by:
windowDeactivatedin interfacejava.awt.event.WindowListener
-
createImageIcon
protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
Create an ImageIcon from the path.- Parameters:
path- the path to the image- Returns:
- the ImageIcon
-
getResourceURL
public static java.net.URL getResourceURL(java.lang.String path)
Get the resource URL from the path.- Parameters:
path- the path to the resource- Returns:
- the URL of the resource
-
performCommandLineRequests
public static void performCommandLineRequests(GExpert exp, boolean breakOnProve)
Perform command line requests. In the array commandlineCommand there are the commands requested by the user and in the array commandLineSrc the parameters for them. Some commands (now it is the "Prove" command) may be done asynchronous, so we cannot wait for their finish her and cannot continue with the remaining requests. Instead, we will continue performing the requests later, when the asynchronous command finishes.- Parameters:
exp- a GExpert instancebreakOnProve- if the "Prove" command should be assumed as an asynchronous call
-
setLookAndFeel
public static void setLookAndFeel()
-
main
public static void main(java.lang.String[] args)
Main entry point of the application. Processes command line options and initializes the GUI.- Parameters:
args- command line arguments.
-
isRunningFromJar
public static boolean isRunningFromJar()
Checks if the application is running in a JAR file (including CheerpJ web environment).- Returns:
- true if running from a JAR file, false otherwise.
-
isRunningInCheerpJ
public static boolean isRunningInCheerpJ()
Checks if the application is running in a CheerpJ web environment.- Returns:
- true if likely running in CheerpJ, false otherwise.
-
openURL
public static void openURL(java.lang.String url)
Opens the specified URL in the system's default web browser or handles it appropriately for the current environment (desktop or web/CheerpJ).- Parameters:
url- the URL to open.
-
saveAsPDF
public void saveAsPDF()
Saves the current view as a PDF file. Prompts the user to choose a file and generates the PDF output.
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
Handles key typed events.- Specified by:
keyTypedin interfacejava.awt.event.KeyListener- Parameters:
e- the key event.
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
Handles key pressed events.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener- Parameters:
e- the key event.
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
Handles key released events.- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener- Parameters:
e- the key event.
-
setUIFont
public static void setUIFont(javax.swing.plaf.FontUIResource f)
Sets the default UI font for all components.- Parameters:
f- the FontUIResource to be used.
-
start
public void start()
Starts or initializes the component.
-
stop
public void stop()
Stops or cleans up the component.
-
updateActionPool
public void updateActionPool(int n)
Updates the action pool using the currently selected list of objects.- Parameters:
n- the pool identifier to update.
-
setActionPool
public void setActionPool(int a)
Configures the action pool based on the specified pool type.- Parameters:
a- the pool type identifier.
-
onKeyCancel
public void onKeyCancel()
Cancels the current action triggered by key events.
-
initKeyMap
public void initKeyMap()
Initializes the key mapping by registering a KeyEventPostProcessor.
-
-