use of org.gephi.graph.api.GraphController in project gephi by gephi.
the class DynamicSettingsPanel method createValidation.
public void createValidation(ValidationGroup group) {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel();
TimeFormat timeFormat = graphModel.getTimeFormat();
if (timeFormat == TimeFormat.DOUBLE) {
group.add(windowTextField, Validators.REQUIRE_NON_EMPTY_STRING, Validators.numberRange(Double.MIN_VALUE, (bounds.getHigh() - bounds.getLow())));
group.add(tickTextField, Validators.REQUIRE_NON_EMPTY_STRING, Validators.numberRange(Double.MIN_VALUE, (bounds.getHigh() - bounds.getLow())));
} else {
//TODO validation with dates
group.add(windowTextField, Validators.REQUIRE_NON_EMPTY_STRING, new PositiveNumberValidator(), new DateRangeValidator(windowTimeUnitCombo.getModel()));
group.add(tickTextField, Validators.REQUIRE_NON_EMPTY_STRING, new PositiveNumberValidator(), new DateRangeValidator(tickTimeUnitCombo.getModel()), new TickUnderWindowValidator(timeFormat != TimeFormat.DOUBLE));
}
}
use of org.gephi.graph.api.GraphController in project gephi by gephi.
the class DynamicSettingsPanel method unsetup.
public void unsetup(DynamicStatistics dynamicStatistics) {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel();
TimeFormat timeFormat = graphModel.getTimeFormat();
//Bounds is the same
dynamicStatistics.setBounds(bounds);
//Window
double window;
if (timeFormat == TimeFormat.DOUBLE) {
window = Double.parseDouble(windowTextField.getText());
} else {
TimeUnit timeUnit = getSelectedTimeUnit(windowTimeUnitCombo.getModel());
window = getTimeInMilliseconds(windowTextField.getText(), timeUnit);
}
dynamicStatistics.setWindow(window);
//Tick
double tick;
if (timeFormat == TimeFormat.DOUBLE) {
tick = Double.parseDouble(tickTextField.getText());
} else {
TimeUnit timeUnit = getSelectedTimeUnit(tickTimeUnitCombo.getModel());
tick = getTimeInMilliseconds(tickTextField.getText(), timeUnit);
}
dynamicStatistics.setTick(tick);
//Save latest selected item
if (timeFormat != TimeFormat.DOUBLE) {
saveDefaultTimeUnits();
}
}
use of org.gephi.graph.api.GraphController in project gephi by gephi.
the class TextModelImpl method readXML.
public void readXML(XMLStreamReader reader, Workspace workspace) throws XMLStreamException {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController != null ? graphController.getGraphModel(workspace) : null;
List<Column> nodeCols = new ArrayList<>();
List<Column> edgeCols = new ArrayList<>();
boolean nodeColumn = false;
boolean edgeColumn = false;
boolean nodeSizeFac = false;
boolean edgeSizeFac = false;
boolean end = false;
while (reader.hasNext() && !end) {
int type = reader.next();
switch(type) {
case XMLStreamReader.START_ELEMENT:
String name = reader.getLocalName();
if ("shownodelabels".equalsIgnoreCase(name)) {
showNodeLabels = Boolean.parseBoolean(reader.getAttributeValue(null, "enable"));
} else if ("showedgelabels".equalsIgnoreCase(name)) {
showEdgeLabels = Boolean.parseBoolean(reader.getAttributeValue(null, "enable"));
} else if ("selectedOnly".equalsIgnoreCase(name)) {
selectedOnly = Boolean.parseBoolean(reader.getAttributeValue(null, "value"));
} else if ("nodefont".equalsIgnoreCase(name)) {
String nodeFontName = reader.getAttributeValue(null, "name");
int nodeFontSize = Integer.parseInt(reader.getAttributeValue(null, "size"));
int nodeFontStyle = Integer.parseInt(reader.getAttributeValue(null, "style"));
nodeFont = new Font(nodeFontName, nodeFontStyle, nodeFontSize);
} else if ("edgefont".equalsIgnoreCase(name)) {
String edgeFontName = reader.getAttributeValue(null, "name");
int edgeFontSize = Integer.parseInt(reader.getAttributeValue(null, "size"));
int edgeFontStyle = Integer.parseInt(reader.getAttributeValue(null, "style"));
edgeFont = new Font(edgeFontName, edgeFontStyle, edgeFontSize);
} else if ("nodecolor".equalsIgnoreCase(name)) {
nodeColor = ColorUtils.decode(reader.getAttributeValue(null, "value")).getRGBComponents(null);
} else if ("edgecolor".equalsIgnoreCase(name)) {
edgeColor = ColorUtils.decode(reader.getAttributeValue(null, "value")).getRGBComponents(null);
} else if ("nodesizefactor".equalsIgnoreCase(name)) {
nodeSizeFac = true;
} else if ("edgesizefactor".equalsIgnoreCase(name)) {
edgeSizeFac = true;
} else if ("colormode".equalsIgnoreCase(name)) {
String colorModeClass = reader.getAttributeValue(null, "class");
if (colorModeClass.equals("TextColorMode")) {
colorMode = VizController.getInstance().getTextManager().getColorModes()[2];
} else if (colorModeClass.equals("ObjectColorMode")) {
colorMode = VizController.getInstance().getTextManager().getColorModes()[1];
} else {
colorMode = VizController.getInstance().getTextManager().getColorModes()[0];
}
} else if ("sizemode".equalsIgnoreCase(name)) {
String sizeModeClass = reader.getAttributeValue(null, "class");
if (sizeModeClass.equals("FixedSizeMode")) {
sizeMode = VizController.getInstance().getTextManager().getSizeModes()[0];
} else if (sizeModeClass.equals("ProportionalSizeMode")) {
sizeMode = VizController.getInstance().getTextManager().getSizeModes()[2];
} else if (sizeModeClass.equals("ScaledSizeMode")) {
sizeMode = VizController.getInstance().getTextManager().getSizeModes()[1];
}
} else if ("nodecolumns".equalsIgnoreCase(name)) {
nodeColumn = true;
} else if ("edgecolumns".equalsIgnoreCase(name)) {
edgeColumn = true;
} else if ("column".equalsIgnoreCase(name)) {
String id = reader.getAttributeValue(null, "id");
if (nodeColumn && graphModel != null) {
Column col = graphModel.getNodeTable().getColumn(id);
if (col != null) {
nodeCols.add(col);
}
} else if (edgeColumn && graphModel != null) {
Column col = graphModel.getEdgeTable().getColumn(id);
if (col != null) {
edgeCols.add(col);
}
}
}
break;
case XMLStreamReader.CHARACTERS:
if (!reader.isWhiteSpace() && nodeSizeFac) {
nodeSizeFactor = Float.parseFloat(reader.getText());
} else if (!reader.isWhiteSpace() && edgeSizeFac) {
edgeSizeFactor = Float.parseFloat(reader.getText());
}
break;
case XMLStreamReader.END_ELEMENT:
nodeSizeFac = false;
edgeSizeFac = false;
if ("nodecolumns".equalsIgnoreCase(reader.getLocalName())) {
nodeColumn = false;
} else if ("edgecolumns".equalsIgnoreCase(reader.getLocalName())) {
edgeColumn = false;
} else if ("textmodel".equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
break;
}
}
nodeTextColumns = nodeCols.toArray(new Column[0]);
edgeTextColumns = edgeCols.toArray(new Column[0]);
}
Aggregations