Package org.apache.batik.apps.svgbrowser
Class Main
- java.lang.Object
-
- org.apache.batik.apps.svgbrowser.Main
-
- All Implemented Interfaces:
Application
public class Main extends java.lang.Object implements Application
This class contains the main method of an SVG viewer.- Version:
- $Id: Main.java 1804130 2017-08-04 14:41:11Z ssteiner $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMain.FontSizeHandlerTo handle the '-font-size' option.protected static interfaceMain.OptionHandlerThis interface represents an option handler.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]argumentsThe arguments.static java.lang.StringBATIK_CONFIGURATION_SUBDIRECTORYBatik configuration sub-directoryprotected static java.util.ResourceBundlebundleThe resource bundlestatic java.lang.StringDEFAULT_DEFAULT_FONT_FAMILYDefault font-family value.protected static javax.swing.ImageIconframeIconThe frame's icon.protected java.util.MaphandlersThe option handlers.protected java.util.VectorlastVisitedThe array of last visited URIsstatic intMAX_VISITED_URISMaximum number of recently visited URIsprotected intmaxVisitedURIsThe actual allowed maximum number of last visited URIsprotected booleanoverrideSecurityPolicyControls whether the application can override the system security policy property.static java.lang.StringPOLICY_GRANT_SCRIPT_FILE_ACCESSEntry for granting file system access to scriptsstatic java.lang.StringPOLICY_GRANT_SCRIPT_NETWORK_ACCESSEntry for granting network access to scriptsstatic java.lang.StringPREFERENCE_KEY_VISITED_URI_LISTEntry for the list of recently visited URIstatic java.lang.StringPREFERENCE_KEY_VISITED_URI_LIST_LENGTHEntry for the maximum number of last visited URIsprotected PreferenceDialogpreferenceDialogThe preference dialog.protected XMLPreferenceManagerpreferenceManagerThe preference manager.static java.lang.StringPROPERTY_JAVA_SECURITY_POLICYSystem property for specifying an additional policy file.static java.lang.StringPROPERTY_USER_HOMEUser home propertyprotected static ResourceManagerresourcesThe resource managerstatic java.lang.StringRESOURCESThe gui resources file nameprotected ApplicationSecurityEnforcersecurityEnforcerScript security enforcement is delegated to the security utilitystatic java.lang.StringSQUIGGLE_CONFIGURATION_FILEName of the Squiggle configuration filestatic java.lang.StringSQUIGGLE_POLICY_FILEName of the Squiggle policy filestatic java.lang.StringSQUIGGLE_SECURITY_POLICYURL for Squiggle's security policy filestatic java.lang.StringSVG_INITIALIZATIONSVG initialization file, used to trigger loading of most of the Batik classesprotected java.lang.StringsvgInitializationURIStores the initialization file URIprotected java.lang.StringuiSpecializationThe UI specialization to use in the JSVGViewerFrames.static java.lang.StringUNKNOWN_SCRIPT_TYPE_LOAD_KEY_EXTENSIONExtension used in addition to the scriptType value to read from the PreferenceManager whether or not the scriptType can be loaded.static java.lang.StringURI_SEPARATORList of separators between URI values in the preference fileprotected java.util.ListviewerFramesThe viewer frames.
-
Constructor Summary
Constructors Constructor Description Main(java.lang.String[] args)Creates a new application.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddVisitedURI(java.lang.String uri)Notifies Application of recently visited URIbooleancanLoadScriptType(java.lang.String scriptType)Returns true if the input scriptType can be loaded in this application.voidcloseJSVGViewerFrame(JSVGViewerFrame f)Closes the given viewer frame.JSVGViewerFramecreateAndShowJSVGViewerFrame()Creates and shows a new viewer frame.javax.swing.ActioncreateExitAction(JSVGViewerFrame vf)Creates a new application exit action.intgetAllowedExternalResourceOrigin()Returns the allowed origins for external resources.intgetAllowedScriptOrigin()Returns the allowed origins for scripts.java.lang.StringgetDefaultFontFamily()Returns the default value for the CSS "font-family" propertyjava.lang.StringgetLanguages()Returns the user languages.java.lang.StringgetMedia()Returns the CSS media to use.java.lang.StringgetUISpecialization()Returns the UI resource specialization to use.java.lang.StringgetUserStyleSheetURI()Returns the user stylesheet uri.java.lang.String[]getVisitedURIs()Asks Application for a list of recently visited URI.java.lang.StringgetXMLParserClassName()Returns the XML parser class name.protected voidinitializeLastVisited()Initializes the lastVisited arrayvoidinstallCustomPolicyFile()Installs a custom policy file in the '.batik' directory.booleanisSelectionOverlayXORMode()Returns true if the selection overlay is painted in XOR mode, false otherwise.booleanisXMLParserValidating()Returns true if the XML parser must be in validation mode, false otherwise.static voidmain(java.lang.String[] args)Creates a viewer frame and shows it..voidopenLink(java.lang.String url)Opens the given link in a new window.protected voidprintUsage()Prints the command line usage.voidrun()Runs the application.private voidsetPreferences()private voidsetPreferences(JSVGViewerFrame vf)voidshowPreferenceDialog(JSVGViewerFrame f)Shows the preference dialog.
-
-
-
Field Detail
-
UNKNOWN_SCRIPT_TYPE_LOAD_KEY_EXTENSION
public static final java.lang.String UNKNOWN_SCRIPT_TYPE_LOAD_KEY_EXTENSION
Extension used in addition to the scriptType value to read from the PreferenceManager whether or not the scriptType can be loaded.- See Also:
- Constant Field Values
-
PROPERTY_USER_HOME
public static final java.lang.String PROPERTY_USER_HOME
User home property- See Also:
- Constant Field Values
-
PROPERTY_JAVA_SECURITY_POLICY
public static final java.lang.String PROPERTY_JAVA_SECURITY_POLICY
System property for specifying an additional policy file.- See Also:
- Constant Field Values
-
BATIK_CONFIGURATION_SUBDIRECTORY
public static final java.lang.String BATIK_CONFIGURATION_SUBDIRECTORY
Batik configuration sub-directory- See Also:
- Constant Field Values
-
SQUIGGLE_CONFIGURATION_FILE
public static final java.lang.String SQUIGGLE_CONFIGURATION_FILE
Name of the Squiggle configuration file- See Also:
- Constant Field Values
-
SQUIGGLE_POLICY_FILE
public static final java.lang.String SQUIGGLE_POLICY_FILE
Name of the Squiggle policy file- See Also:
- Constant Field Values
-
POLICY_GRANT_SCRIPT_NETWORK_ACCESS
public static final java.lang.String POLICY_GRANT_SCRIPT_NETWORK_ACCESS
Entry for granting network access to scripts- See Also:
- Constant Field Values
-
POLICY_GRANT_SCRIPT_FILE_ACCESS
public static final java.lang.String POLICY_GRANT_SCRIPT_FILE_ACCESS
Entry for granting file system access to scripts- See Also:
- Constant Field Values
-
PREFERENCE_KEY_VISITED_URI_LIST
public static final java.lang.String PREFERENCE_KEY_VISITED_URI_LIST
Entry for the list of recently visited URI- See Also:
- Constant Field Values
-
PREFERENCE_KEY_VISITED_URI_LIST_LENGTH
public static final java.lang.String PREFERENCE_KEY_VISITED_URI_LIST_LENGTH
Entry for the maximum number of last visited URIs- See Also:
- Constant Field Values
-
URI_SEPARATOR
public static final java.lang.String URI_SEPARATOR
List of separators between URI values in the preference file- See Also:
- Constant Field Values
-
DEFAULT_DEFAULT_FONT_FAMILY
public static final java.lang.String DEFAULT_DEFAULT_FONT_FAMILY
Default font-family value.- See Also:
- Constant Field Values
-
SVG_INITIALIZATION
public static final java.lang.String SVG_INITIALIZATION
SVG initialization file, used to trigger loading of most of the Batik classes- See Also:
- Constant Field Values
-
svgInitializationURI
protected java.lang.String svgInitializationURI
Stores the initialization file URI
-
RESOURCES
public static final java.lang.String RESOURCES
The gui resources file name- See Also:
- Constant Field Values
-
SQUIGGLE_SECURITY_POLICY
public static final java.lang.String SQUIGGLE_SECURITY_POLICY
URL for Squiggle's security policy file- See Also:
- Constant Field Values
-
bundle
protected static java.util.ResourceBundle bundle
The resource bundle
-
resources
protected static ResourceManager resources
The resource manager
-
frameIcon
protected static javax.swing.ImageIcon frameIcon
The frame's icon.
-
preferenceManager
protected XMLPreferenceManager preferenceManager
The preference manager.
-
MAX_VISITED_URIS
public static final int MAX_VISITED_URIS
Maximum number of recently visited URIs- See Also:
- Constant Field Values
-
lastVisited
protected java.util.Vector lastVisited
The array of last visited URIs
-
maxVisitedURIs
protected int maxVisitedURIs
The actual allowed maximum number of last visited URIs
-
arguments
protected java.lang.String[] arguments
The arguments.
-
overrideSecurityPolicy
protected boolean overrideSecurityPolicy
Controls whether the application can override the system security policy property. This is done when there was no initial security policy specified when the application started, in which case Batik will use that property.
-
securityEnforcer
protected ApplicationSecurityEnforcer securityEnforcer
Script security enforcement is delegated to the security utility
-
handlers
protected java.util.Map handlers
The option handlers.
-
viewerFrames
protected java.util.List viewerFrames
The viewer frames.
-
preferenceDialog
protected PreferenceDialog preferenceDialog
The preference dialog.
-
uiSpecialization
protected java.lang.String uiSpecialization
The UI specialization to use in the JSVGViewerFrames.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Creates a viewer frame and shows it..- Parameters:
args- The command-line arguments.
-
installCustomPolicyFile
public void installCustomPolicyFile() throws java.io.IOExceptionInstalls a custom policy file in the '.batik' directory. This is initialized with the content of the policy file coming with the distribution- Throws:
java.io.IOException
-
run
public void run()
Runs the application.
-
printUsage
protected void printUsage()
Prints the command line usage.
-
createAndShowJSVGViewerFrame
public JSVGViewerFrame createAndShowJSVGViewerFrame()
Creates and shows a new viewer frame.- Specified by:
createAndShowJSVGViewerFramein interfaceApplication
-
closeJSVGViewerFrame
public void closeJSVGViewerFrame(JSVGViewerFrame f)
Closes the given viewer frame.- Specified by:
closeJSVGViewerFramein interfaceApplication
-
createExitAction
public javax.swing.Action createExitAction(JSVGViewerFrame vf)
Creates a new application exit action.- Specified by:
createExitActionin interfaceApplication
-
openLink
public void openLink(java.lang.String url)
Opens the given link in a new window.- Specified by:
openLinkin interfaceApplication
-
getXMLParserClassName
public java.lang.String getXMLParserClassName()
Returns the XML parser class name.- Specified by:
getXMLParserClassNamein interfaceApplication
-
isXMLParserValidating
public boolean isXMLParserValidating()
Returns true if the XML parser must be in validation mode, false otherwise.- Specified by:
isXMLParserValidatingin interfaceApplication
-
showPreferenceDialog
public void showPreferenceDialog(JSVGViewerFrame f)
Shows the preference dialog.- Specified by:
showPreferenceDialogin interfaceApplication
-
setPreferences
private void setPreferences() throws java.io.IOException- Throws:
java.io.IOException
-
setPreferences
private void setPreferences(JSVGViewerFrame vf)
-
getLanguages
public java.lang.String getLanguages()
Returns the user languages.- Specified by:
getLanguagesin interfaceApplication
-
getUserStyleSheetURI
public java.lang.String getUserStyleSheetURI()
Returns the user stylesheet uri.- Specified by:
getUserStyleSheetURIin interfaceApplication- Returns:
- null if no user style sheet was specified.
-
getDefaultFontFamily
public java.lang.String getDefaultFontFamily()
Returns the default value for the CSS "font-family" property- Specified by:
getDefaultFontFamilyin interfaceApplication
-
getMedia
public java.lang.String getMedia()
Returns the CSS media to use.- Specified by:
getMediain interfaceApplication- Returns:
- empty string if no CSS media was specified.
-
isSelectionOverlayXORMode
public boolean isSelectionOverlayXORMode()
Returns true if the selection overlay is painted in XOR mode, false otherwise.- Specified by:
isSelectionOverlayXORModein interfaceApplication
-
canLoadScriptType
public boolean canLoadScriptType(java.lang.String scriptType)
Returns true if the input scriptType can be loaded in this application.- Specified by:
canLoadScriptTypein interfaceApplication
-
getAllowedScriptOrigin
public int getAllowedScriptOrigin()
Returns the allowed origins for scripts.- Specified by:
getAllowedScriptOriginin interfaceApplication- See Also:
ResourceOrigin
-
getAllowedExternalResourceOrigin
public int getAllowedExternalResourceOrigin()
Returns the allowed origins for external resources.- Specified by:
getAllowedExternalResourceOriginin interfaceApplication- See Also:
ResourceOrigin
-
addVisitedURI
public void addVisitedURI(java.lang.String uri)
Notifies Application of recently visited URI- Specified by:
addVisitedURIin interfaceApplication
-
getVisitedURIs
public java.lang.String[] getVisitedURIs()
Asks Application for a list of recently visited URI.- Specified by:
getVisitedURIsin interfaceApplication
-
getUISpecialization
public java.lang.String getUISpecialization()
Returns the UI resource specialization to use.- Specified by:
getUISpecializationin interfaceApplication
-
initializeLastVisited
protected void initializeLastVisited()
Initializes the lastVisited array
-
-