use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class Overview method setDirty.
/**
* Used to mark a sketch as dirty or not. Since it's only marked as
* non-dirty when saving, we mark all the current node/view positions if
* setting non-dirty.
*
* @param inDirty
* NEw dirtiness.
*/
public void setDirty(boolean inDirty) {
_dirty = inDirty;
if (_dirty) {
getDocInfo().updateModificationDate();
}
if (!_dirty) {
for (SketchNode n : _sketchNodes.values()) {
n.savePosition();
}
for (ViewNode v : _viewNodes.values()) {
v.savePosition();
}
}
_appFrame.setDirty(_dirty);
}
use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class OverviewFileIO method overviewToXML.
/**
* Converts an overview to an XML file. Returns the success of the save.
*
* @param outputFile
* The file we will output to
* @param overview
* The sketch we're reading to
* @return True if successful, false otherwise
*/
public static boolean overviewToXML(File outputFile, Overview overview) {
Document overviewAsXML;
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = docBuilderFactory.newDocumentBuilder();
overviewAsXML = db.newDocument();
Element rootElement = overviewAsXML.createElement("easketch_overview");
Element header = overviewAsXML.createElement("header");
Element sketches = overviewAsXML.createElement("sketches");
Element views = overviewAsXML.createElement("views");
// Add Header info to document
DocumentInfo d = overview.getDocInfo();
Element name = overviewAsXML.createElement("title");
name.appendChild(overviewAsXML.createTextNode(d.getName()));
header.appendChild(name);
for (String aut : d.getAuthors()) {
Element author = overviewAsXML.createElement("author");
author.appendChild(overviewAsXML.createTextNode(aut));
header.appendChild(author);
}
Element desc = overviewAsXML.createElement("description");
desc.appendChild(overviewAsXML.createTextNode(d.getDesc()));
header.appendChild(desc);
Element creationDate = overviewAsXML.createElement("creationDate");
creationDate.appendChild(overviewAsXML.createTextNode(EasikConstants.XML_DATETIME.format(d.getCreationDate())));
header.appendChild(creationDate);
Element modDate = overviewAsXML.createElement("lastModificationDate");
modDate.appendChild(overviewAsXML.createTextNode(EasikConstants.XML_DATETIME.format(d.getModificationDate())));
header.appendChild(modDate);
// Loop through sketches, add them to the document
for (SketchNode currentSketch : overview.getSketches()) {
if (currentSketch != null) {
Element thisSketch = SketchFileIO.sketchToElement(overviewAsXML, currentSketch.getFrame().getMModel());
thisSketch.setAttribute("name", currentSketch.toString());
thisSketch.setAttribute("x", currentSketch.getX() + "");
thisSketch.setAttribute("y", currentSketch.getY() + "");
Cascade c = currentSketch.getFrame().getMModel().getDefaultCascading();
Cascade cp = currentSketch.getFrame().getMModel().getDefaultPartialCascading();
thisSketch.setAttribute("cascade", (c == Cascade.CASCADE) ? "cascade" : "restrict");
thisSketch.setAttribute("partial-cascade", (cp == Cascade.CASCADE) ? "cascade" : (cp == Cascade.RESTRICT) ? "restrict" : "set_null");
sketches.appendChild(thisSketch);
}
}
for (ViewNode currentView : overview.getViews()) {
if (currentView != null) {
Element thisView = viewToElement(overviewAsXML, currentView.getFrame().getMModel());
thisView.setAttribute("name", currentView.toString());
thisView.setAttribute("x", currentView.getX() + "");
thisView.setAttribute("y", currentView.getY() + "");
ViewDefinitionEdge thisViewEdge = overview.getViewEdge(currentView.getFrame().getMModel());
thisView.setAttribute("viewDefinitionEdge", thisViewEdge.getName());
thisView.setAttribute("on_sketch", thisViewEdge.getTargetNode().getName());
views.appendChild(thisView);
}
}
// Add root elements to document
overviewAsXML.appendChild(rootElement);
rootElement.appendChild(header);
rootElement.appendChild(sketches);
rootElement.appendChild(views);
} catch (Exception e) {
e.printStackTrace();
overviewAsXML = null;
}
outputXMLtoFile(outputFile, overviewAsXML);
return true;
}
use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class OverviewGraphModel method getAttributes.
/**
* Overridden method to get cell attributes; we make sure the appropriate
* attributes are applied to the Easik objects before returning them.
*
* @see DefaultGraphModel.getAttributes(Object)
*
* @param o
*
* @return
*/
@Override
public AttributeMap getAttributes(Object o) {
if (o instanceof GraphCell) {
GraphCell cell = (GraphCell) o;
AttributeMap attribs = cell.getAttributes();
AttributeMap easikAttribs = null;
if (cell instanceof SketchNode) {
easikAttribs = sketchAttributes((SketchNode) cell);
} else if (cell instanceof ViewNode) {
easikAttribs = viewAttributes((ViewNode) cell);
} else if (cell instanceof ViewDefinitionEdge) {
easikAttribs = viewEdgeAttributes((ViewDefinitionEdge) cell);
// easikAttribs =
// easik.sketch.util.graph.SketchGraphModel.normalEdgeAttributes();
}
if (easikAttribs != null) {
if (_overview.isCellSelected(cell)) {
Color selColor = getColor("selection");
float lineWidth = getWidth("selection", 3);
int borderWidth = 1;
Border currentBorder = GraphConstants.getBorder(easikAttribs);
if (currentBorder instanceof LineBorder) {
borderWidth = ((LineBorder) currentBorder).getThickness();
}
GraphConstants.setBorder(easikAttribs, BorderFactory.createLineBorder(selColor, borderWidth));
GraphConstants.setForeground(easikAttribs, selColor);
GraphConstants.setLineColor(easikAttribs, selColor);
GraphConstants.setLineWidth(easikAttribs, lineWidth);
}
if (attribs == null) {
cell.setAttributes(easikAttribs);
attribs = easikAttribs;
} else {
attribs.applyMap(easikAttribs);
}
return attribs;
}
}
return super.getAttributes(o);
}
use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class JDBCExporter method createViews.
/**
* Generates views on the sketch.
*
* @return list of queries to create our views
*/
protected List<String> createViews() {
final List<String> viewSQL = new LinkedList<>();
final Set<ViewNode> views = new HashSet<>(sketch.getViews());
for (final ViewNode node : views) {
viewSQL.addAll(createView(node));
}
return viewSQL;
}
use of easik.overview.vertex.ViewNode in project fql by CategoricalData.
the class SketchEdge method setName.
/**
* Sets the name of this edge.
*
* @param inName
* The unique name of the edge.
*/
public void setName(String inName) {
final String oldName = getName();
inName = _sourceObj.getMModel().edgeRenamed(this, oldName, inName);
for (ViewNode v : _sourceObj.getMModel().getViews()) {
if (v.getMModel().getEdges().containsKey(oldName)) {
v.getMModel().getEdges().get(oldName).setName(inName);
}
}
_uniqueName = inName;
_sourceObj.getMModel().refresh(this);
}
Aggregations