public class SVGModel extends Object implements com.google.gwt.event.dom.client.MouseDownHandler, com.google.gwt.event.dom.client.MouseMoveHandler, com.google.gwt.event.dom.client.MouseUpHandler, HasScalingHandlers, HasRotationHandlers
Modifier and Type | Field and Description |
---|---|
protected float |
angle
The current scaling the xform group and twin group
|
protected CommandStore |
commandStore
The Store which contains this model commands
|
protected Map<org.vectomatic.dom.svg.impl.SVGElement,SVGElementModel> |
elementToModel
Associates SVG elements with their model wrapper
|
static String |
EXT_TWIN
Id Prefix extension for twins
|
protected Grid |
grid
The grid settings for this model
|
protected SVGElementModel |
highlightedModel
The highlighted model in highlighting mode
|
protected boolean |
highlightingMode
The current mode (false = display mode, true = highlighting mode)
|
protected String |
idPrefix
The prefix used for all id attributes in this model
|
protected Map<String,Object> |
idToModel
Associates element ids with their model
|
protected org.vectomatic.dom.svg.OMSVGMatrix |
m
The matrix transform to the xform group and twin group
|
protected SVGElementModel |
modelGroup
The root of the model tree.
|
protected float |
scale
The current rotation of the xform group and twin group
|
protected SVGSelectionModel |
selectionModel
The selection model
|
protected com.extjs.gxt.ui.client.store.TreeStore<SVGElementModel> |
store
The Store which contains this model data
|
protected org.vectomatic.dom.svg.OMSVGSVGElement |
svg
The root of the SVG document
|
protected static Map<String,MetaModel<org.vectomatic.dom.svg.impl.SVGElement>> |
tagNameToMetamodel |
protected Map<String,Integer> |
tagNameToTagCount
A map used to generate node names for nodes
which do not have a title element.
|
protected SVGViewBoxElementModel |
viewBox
The svg rect use to represent the viewBox
|
protected org.vectomatic.dom.svg.OMSVGRect |
windowRect
A rectangled defining the bounds of the GXT viewport
|
protected org.vectomatic.dom.svg.OMSVGGElement |
xformGroup
A group used to apply a visualization transform change the display
of the document.
|
Constructor and Description |
---|
SVGModel() |
Modifier and Type | Method and Description |
---|---|
void |
add(SVGElementModel parentModel,
SVGElementModel model)
Appends a model to the children of the specified model
|
com.google.gwt.event.shared.HandlerRegistration |
addRotationHandler(RotationHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addScalingHandler(ScalingHandler handler) |
protected void |
adopt(SVGElementModel model) |
protected void |
adopt(SVGElementModel model,
boolean root) |
SVGElementModel |
clone(SVGElementModel model,
String name)
Recursively clones the specified model.
|
boolean |
contains(org.vectomatic.dom.svg.impl.SVGElement element)
Return true if the specified SVG element is part of this model
|
SVGElementModel |
convert(org.vectomatic.dom.svg.impl.SVGElement element)
Generates a model around an overlay type node
|
SVGElementModel |
create(com.google.gwt.dom.client.Node modelNode,
com.google.gwt.dom.client.Node modelTwin) |
org.vectomatic.dom.svg.OMSVGElement |
dereference(String idref) |
void |
displayTwin(SVGElementModel model,
boolean value) |
void |
fireEvent(com.google.gwt.event.shared.GwtEvent<?> event) |
String |
generateName(SVGElementModel model) |
CommandStore |
getCommandStore()
Returns the CommandStore which contains this model commands
|
org.vectomatic.dom.svg.OMSVGPoint |
getCoordinates(com.google.gwt.event.dom.client.MouseEvent<? extends com.google.gwt.event.shared.EventHandler> e,
boolean snap)
Returns the coordinates of a mouse event, converted
to the coordinate system of the model
|
org.vectomatic.dom.svg.OMSVGGElement |
getElementGroup() |
Grid |
getGrid()
Returns this document grid
|
String |
getIdPrefix()
Returns the document id prefix.
|
String |
getMarkup() |
static MetaModel<org.vectomatic.dom.svg.impl.SVGElement> |
getMetamodel(org.vectomatic.dom.svg.impl.SVGElement element) |
SVGElementModel |
getRoot()
Returns the root node of this model
|
float |
getRotation() |
float |
getScale()
Returns the scaling of the SVG.
|
com.extjs.gxt.ui.client.widget.treepanel.TreePanelSelectionModel<SVGElementModel> |
getSelectionModel()
Returns the selection model.
|
com.extjs.gxt.ui.client.store.TreeStore<SVGElementModel> |
getStore()
Returns the Store which contains this model data
|
org.vectomatic.dom.svg.OMSVGSVGElement |
getSvgElement() |
org.vectomatic.dom.svg.OMSVGGElement |
getTwinGroup() |
static float |
getVertexSize(org.vectomatic.dom.svg.itf.ISVGLocatable element) |
static float |
getVertexSize(SVGElementModel model)
Computes the size of the vertex representation (it should be 1mm
whatever the scaling factor).
|
SVGViewBoxElementModel |
getViewBox()
Returns the model viewBox.
|
org.vectomatic.dom.svg.OMSVGRect |
getWindowRect() |
void |
highlightModel(SVGElementModel model) |
void |
insertBefore(SVGElementModel parentModel,
SVGElementModel newModel,
SVGElementModel refModel)
Insert a new model into this SVG model before the specified child model
or the specified parent model.
|
boolean |
isHighlightingMode() |
static SVGModel |
newInstance(org.vectomatic.dom.svg.OMSVGSVGElement svg,
String title,
String idPrefix)
Factory method.
|
void |
onAttach() |
void |
onKeyPress(com.extjs.gxt.ui.client.event.ComponentEvent event) |
void |
onKeyUp(com.extjs.gxt.ui.client.event.ComponentEvent event) |
void |
onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent event) |
void |
onMouseMove(com.google.gwt.event.dom.client.MouseMoveEvent event) |
void |
onMouseUp(com.google.gwt.event.dom.client.MouseUpEvent event) |
protected void |
orphan(SVGElementModel model) |
protected void |
orphan(SVGElementModel model,
boolean root) |
void |
remove(SVGElementModel model)
Removes the specified model
|
void |
setHighlightingMode(boolean highlightingMode) |
void |
setRotation(float angle)
Sets the rotation of the SVG.
|
void |
setScale(float scale)
Sets the scaling of the SVG.
|
void |
setSvgElement(org.vectomatic.dom.svg.OMSVGSVGElement svg,
String title,
String idPrefix)
Binds this SVG model to the specified SVG 'svg' element
|
void |
setWindowRect(int width,
int height)
Specifies the dimensions of the window viewport
|
protected void |
storeUpdate(com.extjs.gxt.ui.client.store.StoreEvent<SVGElementModel> se) |
void |
updateContextMenu(com.extjs.gxt.ui.client.widget.menu.Menu contextMenu)
Updates the context menu based on the model selection
|
void |
updateTransform()
Updates the display group transform and changes the CSS size
of the SVG accordingly
|
public static final String EXT_TWIN
protected String idPrefix
protected org.vectomatic.dom.svg.OMSVGSVGElement svg
protected org.vectomatic.dom.svg.OMSVGGElement xformGroup
protected SVGElementModel modelGroup
protected org.vectomatic.dom.svg.OMSVGMatrix m
protected float angle
protected float scale
protected SVGSelectionModel selectionModel
protected boolean highlightingMode
protected SVGElementModel highlightedModel
protected Map<String,Integer> tagNameToTagCount
protected com.extjs.gxt.ui.client.store.TreeStore<SVGElementModel> store
protected CommandStore commandStore
protected Map<org.vectomatic.dom.svg.impl.SVGElement,SVGElementModel> elementToModel
protected SVGViewBoxElementModel viewBox
protected org.vectomatic.dom.svg.OMSVGRect windowRect
protected Grid grid
public static SVGModel newInstance(org.vectomatic.dom.svg.OMSVGSVGElement svg, String title, String idPrefix)
svg
- The svg roottitle
- The svg titleidPrefix
- the id prefix for this modelpublic static MetaModel<org.vectomatic.dom.svg.impl.SVGElement> getMetamodel(org.vectomatic.dom.svg.impl.SVGElement element)
public SVGElementModel convert(org.vectomatic.dom.svg.impl.SVGElement element)
T
- the node typeelement
- The overlay type nodepublic org.vectomatic.dom.svg.OMSVGSVGElement getSvgElement()
public void setSvgElement(org.vectomatic.dom.svg.OMSVGSVGElement svg, String title, String idPrefix)
svg
- an SVG 'svg' elementtitle
- the name of the root elementidPrefix
- the id prefix for this modelpublic boolean contains(org.vectomatic.dom.svg.impl.SVGElement element)
element
- the element to testprotected void adopt(SVGElementModel model)
protected void adopt(SVGElementModel model, boolean root)
protected void orphan(SVGElementModel model)
protected void orphan(SVGElementModel model, boolean root)
public SVGElementModel create(com.google.gwt.dom.client.Node modelNode, com.google.gwt.dom.client.Node modelTwin)
public void add(SVGElementModel parentModel, SVGElementModel model)
parentModel
- The parent modelmodel
- The model to appendpublic void insertBefore(SVGElementModel parentModel, SVGElementModel newModel, SVGElementModel refModel)
parentModel
- The parent modelnewModel
- The model to insert. If the model is not in this SVG model,
it is removed from its previous SVG model before being inserted into this SVG model.refModel
- The reference model. If null, the new model is appended to
the children of the parent modelpublic void remove(SVGElementModel model)
model
- public SVGElementModel clone(SVGElementModel model, String name)
model
- protected void storeUpdate(com.extjs.gxt.ui.client.store.StoreEvent<SVGElementModel> se)
public String getMarkup()
public SVGElementModel getRoot()
public com.extjs.gxt.ui.client.store.TreeStore<SVGElementModel> getStore()
public CommandStore getCommandStore()
public com.extjs.gxt.ui.client.widget.treepanel.TreePanelSelectionModel<SVGElementModel> getSelectionModel()
public SVGViewBoxElementModel getViewBox()
public String getIdPrefix()
public void onMouseMove(com.google.gwt.event.dom.client.MouseMoveEvent event)
onMouseMove
in interface com.google.gwt.event.dom.client.MouseMoveHandler
public void onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent event)
onMouseDown
in interface com.google.gwt.event.dom.client.MouseDownHandler
public void onMouseUp(com.google.gwt.event.dom.client.MouseUpEvent event)
onMouseUp
in interface com.google.gwt.event.dom.client.MouseUpHandler
public void onKeyPress(com.extjs.gxt.ui.client.event.ComponentEvent event)
public void onKeyUp(com.extjs.gxt.ui.client.event.ComponentEvent event)
public void updateContextMenu(com.extjs.gxt.ui.client.widget.menu.Menu contextMenu)
contextMenu
- The context menu to updatepublic org.vectomatic.dom.svg.OMSVGPoint getCoordinates(com.google.gwt.event.dom.client.MouseEvent<? extends com.google.gwt.event.shared.EventHandler> e, boolean snap)
e
- A mouse eventsnap
- True if the coordinate should be snapped to the grid when
grid snapping is activatedpublic void onAttach()
public float getScale()
public void setScale(float scale)
scale
- The scale (1 means scale 1:1, 2 means scale 2:1)public float getRotation()
public void setRotation(float angle)
angle
- The angle (in degrees)public Grid getGrid()
public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
fireEvent
in interface com.google.gwt.event.shared.HasHandlers
public com.google.gwt.event.shared.HandlerRegistration addRotationHandler(RotationHandler handler)
addRotationHandler
in interface HasRotationHandlers
public com.google.gwt.event.shared.HandlerRegistration addScalingHandler(ScalingHandler handler)
addScalingHandler
in interface HasScalingHandlers
public void setWindowRect(int width, int height)
width
- width of the window viewportheight
- height of the window viewportpublic org.vectomatic.dom.svg.OMSVGRect getWindowRect()
public void updateTransform()
public static float getVertexSize(SVGElementModel model)
public static float getVertexSize(org.vectomatic.dom.svg.itf.ISVGLocatable element)
public org.vectomatic.dom.svg.OMSVGGElement getElementGroup()
public org.vectomatic.dom.svg.OMSVGGElement getTwinGroup()
public boolean isHighlightingMode()
public void setHighlightingMode(boolean highlightingMode)
public void highlightModel(SVGElementModel model)
public void displayTwin(SVGElementModel model, boolean value)
public String generateName(SVGElementModel model)
public org.vectomatic.dom.svg.OMSVGElement dereference(String idref)
Copyright © 2018. All Rights Reserved.