org.autoplot.dom.DomUtil

operations for the DOM, such as search-for-node and child properties

DomUtil( )


STRING_TO_FONT


STRING_TO_COLOR


AUTO_TO_COLOR


abbreviateRight

abbreviateRight( String s, int len ) → String

trim the string on the left, leaving the right visible.

Parameters

s - the string
len - the number of characters

Returns:

"..."+s.substring(s.length() - len)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


applyMacro

applyMacro( org.autoplot.dom.DomNode state, String node, String sval ) → void

Look through the state property values for references to ${PWD} and replace them with sval.

Parameters

state - the domNode, typically starting from the Application root.
node - %{PWD}
sval - /tmp

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


asArrayList

asArrayList( Object[] a ) → java.util.ArrayList

Just like Arrays.toList, but copies into ArrayList so elements may be inserted.

Parameters

a - a java.lang.Object[]

Returns:

ArrayList that can have elements inserted

[search for examples] [view on GitHub] [view on old javadoc] [view source]


checkUniqueIdsAndReferences

checkUniqueIdsAndReferences( org.autoplot.dom.Application dom, java.util.List problems ) → java.util.List

detect where ids are not unique

Parameters

dom - an Application
problems - a java.util.List

Returns:

a java.util.List

See Also:

deleteDuplicateIds which will make the vap valid, at least. which will make the vap valid, at least.
validateDom(org.autoplot.dom.Application, java.util.List)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


childDiff

childDiff( String childName, org.autoplot.dom.Diff diff ) → org.autoplot.dom.Diff

return the child diff in the context of the parent node. May return null if the diff cannot be described.

Parameters

childName - a String
diff - a Diff

Returns:

an org.autoplot.dom.Diff

[search for examples] [view on GitHub] [view on old javadoc] [view source]


childDiffs

childDiffs( String childName, java.util.List diffs ) → java.util.List

return the child diff in the context of the parent node. May return null if the diff cannot be described.

Parameters

childName - a String
diffs - a java.util.List

Returns:

a java.util.List

[search for examples] [view on GitHub] [view on old javadoc] [view source]


copyOverInternalData

copyOverInternalData( org.autoplot.dom.Application srcdom, org.autoplot.dom.Application dstdom ) → void

copy over "vap+internal:" data, where data is found in the controller but no URI represents it. This is to support https://sourceforge.net/p/autoplot/bugs/2332/, where we now copy over any data we find as well.

Parameters

srcdom - the src dom with controllers and possibly internal data.
dstdom - the dst dom with controllers.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


deleteDataSourceFilter

deleteDataSourceFilter( org.autoplot.dom.Application application, org.autoplot.dom.DataSourceFilter dsf ) → void

delete the data source filter.

Parameters

application - an Application
dsf - the data source filter to remove.

Returns:

void (returns nothing)

See Also:

org.autoplot.dom.ApplicationController#deleteDataSourceFilter(org.autoplot.dom.DataSourceFilter)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


deleteDuplicateIds

deleteDuplicateIds( org.autoplot.dom.Application state ) → void

if there are duplicate ids, we can delete them to at least make the vap valid.

Parameters

state - an Application

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


describe

describe( DatumRange init, DatumRange fin ) → String

describe the change in axis range. These include:

Parameters

init - the initial range
fin - the final range

Returns:

the human consumable string, e.g. "zoom out"

[search for examples] [view on GitHub] [view on old javadoc] [view source]


encodeColor

encodeColor( java.awt.Color c ) → String

Parameters

c - a Color

Returns:

java.lang.String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


encodeFont

encodeFont( java.awt.Font f ) → String

Parameters

f - a Font

Returns:

java.lang.String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


findBinding

findBinding( org.autoplot.dom.Application dom, org.autoplot.dom.DomNode src, String srcProp, org.autoplot.dom.DomNode dst, String dstProp ) → org.autoplot.dom.BindingModel

Find the binding, if it exists. All bindingImpls are symmetric, so the src and dst order is ignored in this search.

Parameters

dom - the dom tree
src - a DomNode
srcProp - a String
dst - a DomNode
dstProp - a String

Returns:

the BindingModel or null if it doesn't exist.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


findBindings

findBindings( org.autoplot.dom.Application dom, org.autoplot.dom.DomNode src, String srcProp ) → java.util.List

returns a list of bindings of the node for the property

Parameters

dom - the dom tree
src - the node to which or from which a binding exists
srcProp - the property name of the binding.

Returns:

a java.util.List

[search for examples] [view on GitHub] [view on old javadoc] [view source]

findBindings( org.autoplot.dom.Application dom, org.autoplot.dom.DomNode src, String srcProp, org.autoplot.dom.DomNode dst, String dstProp ) → java.util.List

findElementsById

findElementsById( org.autoplot.dom.DomNode root, String regex ) → java.util.List

find the nodes matching this regex.

Parameters

root - the node to start at.
regex - the regular expression.

Returns:

the nodes.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


findListeners

findListeners( Object o, String prop ) → void

print a list of who is listening to the property

Parameters

o - the dom node or dom node controller.
prop - the property name.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


formatObject

formatObject( Object obj ) → String

Parameters

obj - an Object

Returns:

java.lang.String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getArrayDiffs

getArrayDiffs( String property, Object[] nodes1, Object[] nodes2 ) → java.util.List

list the differences in two arrays of the same type of object. This is the diffs that will make nodes2 look like nodes1. Presently this just identifies inserts and deletes. If the objects are DomNodes, then ids are used to match nodes.

Parameters

property - name used to identify the difference in the result.
nodes1 - list of nodes
nodes2 - list of nodex

Returns:

list of Diffs between the lists.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getBoundsForPlot

getBoundsForPlot( org.autoplot.dom.Application dom, org.autoplot.dom.Plot p ) → java.awt.Rectangle

return the bounds for the plot, including the space needed for the title but not the space needed for the axes. This is not intuitively difficult to do, but since one Row is generally relative to another row, this is not trivial.

Parameters

dom - the layout containing the plot
p - the plot

Returns:

the bounds

See Also:

getRowPositionPixels(org.autoplot.dom.Application, org.autoplot.dom.Row, java.lang.String)
getColumnPositionPixels(org.autoplot.dom.Application, org.autoplot.dom.Column, java.lang.String)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


getBoundsForXAxis

getBoundsForXAxis( org.autoplot.dom.Application dom, org.autoplot.dom.Plot p ) → java.awt.Rectangle

return the bounds for the xaxis, including the space needed for the label. The ephemeris (TCAs) lines needed is not known, so five lines are assumed.

Parameters

dom - the layout containing the plot
p - the plot

Returns:

the bounds

See Also:

getRowPositionPixels(org.autoplot.dom.Application, org.autoplot.dom.Row, java.lang.String)
getColumnPositionPixels(org.autoplot.dom.Application, org.autoplot.dom.Column, java.lang.String)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


getBoundsForZAxis

getBoundsForZAxis( org.autoplot.dom.Application dom, org.autoplot.dom.Plot p ) → java.awt.Rectangle

return the bounds for the colorbar zaxis, including the space needed for the label.

Parameters

dom - the layout containing the plot
p - the plot

Returns:

the bounds

See Also:

getRowPositionPixels(org.autoplot.dom.Application, org.autoplot.dom.Row, java.lang.String)
getColumnPositionPixels(org.autoplot.dom.Application, org.autoplot.dom.Column, java.lang.String)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


getColumnPositionPixels

getColumnPositionPixels( org.autoplot.dom.Application dom, org.autoplot.dom.Column col, String position ) → int

convert the layout to the pixel position if the left side of the column. The one and only canvas is used for the width. Note this is not trivial, because the parent must be considered as well.

Parameters

dom - the layout containing the column, and canvases[0] is used.
col - the column
position - a string like "100%-5em"

Returns:

the position in pixels.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getDataSourceFiltersFor

getDataSourceFiltersFor( org.autoplot.dom.Application dom, org.autoplot.dom.Plot p ) → java.util.List

return the list of DataSourceFilters for a plot.

Parameters

dom - the application
p - the plot

Returns:

new list of dataSourceFilters

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getDiffs

getDiffs( org.autoplot.dom.DomNode node1, org.autoplot.dom.DomNode node2 ) → java.util.List

automatically detect the diffs between two DomNodes of the same type. return the list of diffs that will make node2 look like node1. The property "controller" is ignored.

Parameters

node1 - a DomNode
node2 - a DomNode

Returns:

a java.util.List

[search for examples] [view on GitHub] [view on old javadoc] [view source]

getDiffs( org.autoplot.dom.DomNode node1, org.autoplot.dom.DomNode node2, java.util.List exclude ) → java.util.List

getElementByAddress

getElementByAddress( org.autoplot.dom.DomNode domNode, String address ) → org.autoplot.dom.DomNode

return the node at the address, for example "plots[2].xaxis" of an application.

Parameters

domNode - the initial dom node, like dom.
address - the address, like plots[2].xaxis

Returns:

the domNode at the address.

See Also:

getElementById(org.autoplot.dom.DomNode, java.lang.String) y


[search for examples] [view on GitHub] [view on old javadoc] [view source]


getElementById

getElementById( org.autoplot.dom.DomNode root, String id, boolean allowEmpty ) → org.autoplot.dom.DomNode

like getElementById, but return null if the id is an empty string.

Parameters

root - a DomNode
id - a String
allowEmpty - a boolean

Returns:

an org.autoplot.dom.DomNode

[search for examples] [view on GitHub] [view on old javadoc] [view source]

getElementById( org.autoplot.dom.DomNode root, String id ) → org.autoplot.dom.DomNode

getParentsFor

getParentsFor( org.autoplot.dom.Application dom, String uri ) → java.util.List

return the parent DataSourceFilters for uris like vap+internal:data_1,data_2 Note this was the only way to combine data before the "Data Mashup Tool" was introduced, and the Mashup tool is probably a better way to do this.

Parameters

dom - the dom
uri - the uri, like vap+internal:data_1,data_2

Returns:

the DataSourceFilters

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getPlotAsString

getPlotAsString( org.autoplot.dom.Application application, org.autoplot.dom.Plot domPlot ) → String

this was made public for bug 1520. This returns a 1-plot dom, but this may change.

Parameters

application - an Application
domPlot - a Plot

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getPlotElementsFor

getPlotElementsFor( org.autoplot.dom.Application application, org.autoplot.dom.Plot plot ) → java.util.List

Return the plot elements that contained within a plot.

Parameters

application - the dom for a plot.
plot - the plot containing plot elements.

Returns:

the plot elements contained by the plot.

[search for examples] [view on GitHub] [view on old javadoc] [view source]

getPlotElementsFor( org.autoplot.dom.Application application, org.autoplot.dom.DataSourceFilter dsf ) → java.util.List

getPlotForAxis

getPlotForAxis( org.autoplot.dom.Application app, org.autoplot.dom.Axis oa ) → org.autoplot.dom.Plot

return null or the plot using the axis.

Parameters

app - the application
oa - the axis

Returns:

null or the plot using the axis

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getPropertyType

getPropertyType( org.autoplot.dom.DomNode node, String propertyName ) → java.lang.Class

get the property type, e.g. Datum.class or [Lorg.virbo.autoplot.dom.Canvas (array of Canvases.)

Parameters

node - the dom node
propertyName - the property name

Returns:

the property type

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getPropertyValue

getPropertyValue( org.autoplot.dom.DomNode node, String propertyName ) → Object

get the node property value

Parameters

node - the dom node
propertyName - the property name

Returns:

the node property value

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getRowPositionPixels

getRowPositionPixels( org.autoplot.dom.Application dom, org.autoplot.dom.Row row, String position ) → int

convert the layout to the pixel position if the top of the row. Note this is not trivial, because the parent must be considered as well.

Parameters

dom - the layout containing the row, and canvases[0] is used.
row - the row
position - a string like "100%-1em+1px"

Returns:

the position in pixels

[search for examples] [view on GitHub] [view on old javadoc] [view source]


indexOf

indexOf( java.util.List nodes, Object node ) → int

returns the index by ID, not by equals. Equals cannot be overriden, because property change diffs, etc.

Parameters

nodes - list of nodes
node - the node to search for

Returns:

the index or -1.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


layoutToString

layoutToString( org.autoplot.dom.Canvas c ) → String

print a one-line representation of the layout, showing canvas dimensions, font size, margin row and column, and the first row.

Parameters

c - a Canvas

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


moveToJustAbove

moveToJustAbove( org.autoplot.dom.Application dom, String referenceId, String pId ) → void

move the plot element within the dom below the plot element.

Parameters

dom - the dom (with no controllers)
referenceId - the plot element which is the reference
pId - the plot element to move

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


moveToJustBelow

moveToJustBelow( org.autoplot.dom.Application dom, String referenceId, String pId ) → void

move the plot element within the dom below the plot element.

Parameters

dom - the dom (with no controllers)
referenceId - the plot element which is the reference
pId - the plot element to move

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


nodeHasProperty

nodeHasProperty( org.autoplot.dom.DomNode node1, String property ) → boolean

allow verification that the node has a property. I killed an hour with a bug where I was using "timerange" instead of "timeRange"... Always use the constants: Application.PROP_TIMERANGE

Parameters

node1 - a DomNode
property - a String

Returns:

a boolean

[search for examples] [view on GitHub] [view on old javadoc] [view source]


oneFamily

oneFamily( java.util.List elementsIn ) → boolean

returns true if all the plotElements are a parent and its children.

Parameters

elementsIn - a java.util.List

Returns:

a boolean

[search for examples] [view on GitHub] [view on old javadoc] [view source]


parseObject

parseObject( Object context, String s ) → Object

Parameters

context - an Object
s - a String

Returns:

java.lang.Object

[search for examples] [view on GitHub] [view on old javadoc] [view source]


resolveProperties

resolveProperties( String template, String root, java.util.Map props ) → String

plugs values from USER_PROPERTIES or METADATA into template string.

Parameters

template - template, for example the title or label.
root - USER_PROPERTIES, METADATA, etc.
props - properties tree.

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


setPropertyValue

setPropertyValue( org.autoplot.dom.DomNode node, String propertyName, Object val ) → void

set the property value

Parameters

node - the dom node
propertyName - the property name
val - the new value

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


structureChanges

structureChanges( org.autoplot.dom.Application dom, org.autoplot.dom.Application state ) → boolean

returns true if the dom structure changes. For example the number of plotElements changes, then this returns true. If only the range of an axis changes, then return false; 2012-01-11: check axis units after failure in test002_003 showed that old dataset was used for autoranging.

Parameters

dom - an Application
state - an Application

Returns:

true if the dom structure changes.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


syncTo

syncTo( org.autoplot.dom.DomNode node1, org.autoplot.dom.DomNode node2 ) → void

sync node1 to node2 through introspection. This only works for nodes without controllers, etc. It would be really nice to figure out how to generalize this to include inserted nodes,etc.

Parameters

node1 - a DomNode
node2 - a DomNode

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]

syncTo( org.autoplot.dom.DomNode node1, org.autoplot.dom.DomNode node2, java.util.List exclude ) → void

validateDom

validateDom( org.autoplot.dom.Application application, java.util.List problems ) → boolean

returns true if the dom is valid, throws a runtime exception otherwise

Parameters

application - the dom
problems - descriptions of the problems will be inserted here

Returns:

true if the dom is valid, throws a runtime exception otherwise

See Also:

deleteDuplicateIds(org.autoplot.dom.Application)
checkUniqueIdsAndReferences(org.autoplot.dom.Application, java.util.List)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


vapToJython

vapToJython( org.autoplot.dom.Application app0, org.autoplot.dom.Application app ) → String[]

Ivar requested a vap-to-Jython converter.

Parameters

app0 - an Application
app - an Application

Returns:

a String[]

[search for examples] [view on GitHub] [view on old javadoc] [view source]