treebolic.model
Class Utils

java.lang.Object
  extended by treebolic.model.Utils

public class Utils
extends java.lang.Object

Attribute utilities

Author:
Bernard Bou

Nested Class Summary
static class Utils.StyleComponent
          Style component pointer
 
Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String colorToString(java.awt.Color thisColor)
          Convert color to hexadecimal string
static java.lang.String fillToString(java.lang.Integer thisStyle)
          Convert string to fill code style
static java.util.Properties load(java.net.URL thisUrl)
          Load properties from URL
static java.lang.Integer modifyStyle(java.lang.Integer thisStyle, java.lang.Object thisValue, Utils.StyleComponent thisComponent)
          Modify style
static void parseMenuItem(MenuItem thisMenuItem, java.lang.String thisActionString, java.lang.String thisScopeString, java.lang.String thisModeString)
          Parse strings and set menuitem fields accordingly
static java.lang.Integer parseStyle(java.lang.String thisStroke, java.lang.String thisFromTerminator, java.lang.String thisToTerminator, java.lang.String thisHiddenFlag)
          Parse edge style
static java.lang.String shapeToString(java.lang.Integer thisStyle)
          Convert shape code style to string
static Controller.Action stringToAction(java.lang.String thisActionString)
          Parse menuitem action
static java.awt.Color stringToColor(java.lang.String thisString)
          Convert hexadecimal string to color
static int stringToFill(java.lang.String thisString)
          Convert string to fill code style
static Controller.MatchMode stringToMode(java.lang.String thisModeString)
          Parse menuitem mode
static Controller.MatchScope stringToScope(java.lang.String thisScopeString)
          Parse menuitem scope
static int stringToShape(java.lang.String thisString)
          Convert string to shape code style
static int stringToStroke(java.lang.String thisString)
          Convert string to stroke code
static java.lang.String strokeToString(java.lang.Integer thisStyle)
          Convert stroke code to string
static java.lang.String toString(Controller.Action thisAction)
          Stringify action
static java.lang.String toString(Controller.MatchMode thisMode)
          Stringify mode
static java.lang.String toString(Controller.MatchScope thisScope)
          Stringify scope
static java.lang.String toString(java.lang.Integer thisStyle, Utils.StyleComponent thisComponent)
          Stringify edge style component
static java.lang.String[] toStrings(java.lang.Integer thisStyle)
          Stringify edge style component
static java.lang.String[] toStrings(MenuItem thisMenuItem)
          Parse menuitem action, matchmode, matchscope fields to strings
static java.lang.Boolean toTrueBoolean(java.lang.Integer thisStyle, Utils.StyleComponent thisComponent)
          Convert to boolean (true,null)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

parseStyle

public static java.lang.Integer parseStyle(java.lang.String thisStroke,
                                           java.lang.String thisFromTerminator,
                                           java.lang.String thisToTerminator,
                                           java.lang.String thisHiddenFlag)
Parse edge style

Parameters:
thisStroke - stroke
thisFromTerminator - from-terminator
thisToTerminator - to-terminator
thisHiddenFlag - whether edge is hidden ('true' or 'false')
Returns:
style

modifyStyle

public static java.lang.Integer modifyStyle(java.lang.Integer thisStyle,
                                            java.lang.Object thisValue,
                                            Utils.StyleComponent thisComponent)
Modify style

Parameters:
thisStyle - current style
thisValue - string value
thisComponent - style component to modify
Returns:
modified style

toString

public static java.lang.String toString(java.lang.Integer thisStyle,
                                        Utils.StyleComponent thisComponent)
Stringify edge style component

Parameters:
thisStyle - style
thisComponent - part of style to stringify
Returns:
string

toStrings

public static java.lang.String[] toStrings(java.lang.Integer thisStyle)
Stringify edge style component

Parameters:
thisStyle - style
Returns:
hidden, stroke, fromterminator, toterminator strings

toTrueBoolean

public static java.lang.Boolean toTrueBoolean(java.lang.Integer thisStyle,
                                              Utils.StyleComponent thisComponent)
Convert to boolean (true,null)

Parameters:
thisStyle - style
thisComponent - part of style to convert
Returns:
true or null

stringToStroke

public static int stringToStroke(java.lang.String thisString)
Convert string to stroke code

Parameters:
thisString - stroke string
Returns:
stroke code style

strokeToString

public static java.lang.String strokeToString(java.lang.Integer thisStyle)
Convert stroke code to string

Parameters:
thisStyle - stroke code style
Returns:
stroke string

stringToFill

public static int stringToFill(java.lang.String thisString)
Convert string to fill code style

Parameters:
thisString - fill string
Returns:
fill code style

fillToString

public static java.lang.String fillToString(java.lang.Integer thisStyle)
Convert string to fill code style

Parameters:
thisStyle - fill code style
Returns:
fill string

stringToShape

public static int stringToShape(java.lang.String thisString)
Convert string to shape code style

Parameters:
thisString - shape string
Returns:
shape code style

shapeToString

public static java.lang.String shapeToString(java.lang.Integer thisStyle)
Convert shape code style to string

Parameters:
thisStyle - shape code style
Returns:
shape string

parseMenuItem

public static void parseMenuItem(MenuItem thisMenuItem,
                                 java.lang.String thisActionString,
                                 java.lang.String thisScopeString,
                                 java.lang.String thisModeString)
Parse strings and set menuitem fields accordingly

Parameters:
thisMenuItem - menuitem
thisActionString - action string
thisScopeString - scope string
thisModeString - mode string

stringToAction

public static Controller.Action stringToAction(java.lang.String thisActionString)
Parse menuitem action

Parameters:
thisActionString - action string
Returns:
action

stringToScope

public static Controller.MatchScope stringToScope(java.lang.String thisScopeString)
Parse menuitem scope

Parameters:
thisScopeString - scope string
Returns:
scope

stringToMode

public static Controller.MatchMode stringToMode(java.lang.String thisModeString)
Parse menuitem mode

Parameters:
thisModeString - mode string
Returns:
mode

toString

public static java.lang.String toString(Controller.Action thisAction)
Stringify action

Parameters:
thisAction - action
Returns:
action string

toString

public static java.lang.String toString(Controller.MatchScope thisScope)
Stringify scope

Parameters:
thisScope - scope
Returns:
scope string

toString

public static java.lang.String toString(Controller.MatchMode thisMode)
Stringify mode

Parameters:
thisMode - mode
Returns:
mode string

toStrings

public static java.lang.String[] toStrings(MenuItem thisMenuItem)
Parse menuitem action, matchmode, matchscope fields to strings

Parameters:
thisMenuItem - menuitem
Returns:
action, matchscope, matchmode strings

colorToString

public static java.lang.String colorToString(java.awt.Color thisColor)
Convert color to hexadecimal string

Parameters:
thisColor - color
Returns:
prefixless hexadecimal representation of color

stringToColor

public static java.awt.Color stringToColor(java.lang.String thisString)
Convert hexadecimal string to color

Parameters:
thisString - prefixless hexadecimal representation of color
Returns:
color

load

public static java.util.Properties load(java.net.URL thisUrl)
                                 throws java.io.IOException
Load properties from URL

Parameters:
thisUrl - url of property file to load from
Throws:
java.io.IOException