use of org.csstudio.trends.databrowser3.model.AxisConfig in project org.csstudio.display.builder by kasemir.
the class DataBrowserEditor method init.
/**
* Initialize model from editor input
* {@inheritDoc}
*/
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
setSite(site);
if (input instanceof DataBrowserModelEditorInput) {
// Received model with input
model = ((DataBrowserModelEditorInput) input).getModel();
setInput(input);
} else {
// Create new model
model = new Model();
setInput(new DataBrowserModelEditorInput(input, model));
// Load model content from file
try (final InputStream stream = SingleSourcePlugin.getResourceHelper().getInputStream(input)) {
if (stream != null)
new XMLPersistence().load(model, stream);
} catch (Exception ex) {
throw new PartInitException(NLS.bind(Messages.ConfigFileErrorFmt, input.getName()), ex);
}
}
// Update the editor's name from "Data Browser" to title of model or file name
// See DataBrowserModelEditorInput.getName()
setPartName(getEditorInput().getName());
model_listener = new ModelListenerAdapter() {
@Override
public void changedSaveChangesBehavior(final boolean save_changes) {
is_dirty = save_changes;
firePropertyChange(IEditorPart.PROP_DIRTY);
}
@Override
public void changedTitle() {
setDirty(true);
}
@Override
public void changedLayout() {
setDirty(true);
}
@Override
public void changedTiming() {
setDirty(true);
}
@Override
public void changedArchiveRescale() {
setDirty(true);
}
@Override
public void changedColorsOrFonts() {
setDirty(true);
}
@Override
public void changedTimerange() {
setDirty(true);
}
@Override
public void changeTimeAxisConfig() {
setDirty(true);
}
@Override
public void changedAxis(final Optional<AxisConfig> axis) {
setDirty(true);
}
@Override
public void itemAdded(final ModelItem item) {
setDirty(true);
}
@Override
public void itemRemoved(final ModelItem item) {
setDirty(true);
}
@Override
public void changedItemVisibility(final ModelItem item) {
setDirty(true);
}
@Override
public void changedItemLook(final ModelItem item) {
site.getShell().getDisplay().asyncExec(() -> setDirty(true));
}
@Override
public void changedItemDataConfig(PVItem item) {
setDirty(true);
}
@Override
public void scrollEnabled(final boolean scroll_enabled) {
setDirty(true);
}
@Override
public void changedAnnotations() {
setDirty(true);
}
};
model.addListener(model_listener);
}
use of org.csstudio.trends.databrowser3.model.AxisConfig in project org.csstudio.display.builder by kasemir.
the class PlotDemo method createGUI.
// final private PlotListener listener = new PlotListener()
// {
// @Override
// public void scrollRequested(final boolean enable_scrolling)
// {
// System.out.println("Scroll enabled: " + enable_scrolling);
// scroll = enable_scrolling;
// }
//
// @Override
// public void timeConfigRequested()
// {
// System.out.println("Time Config requested");
// }
//
// @Override
// public void timeAxisChanged(final long start_ms, final long end_ms)
// {
// start_time = TimestampHelper.fromMillisecs(start_ms);
// end_time = TimestampHelper.fromMillisecs(end_ms);
// System.out.println("Time axis: " + start_time + " ... " + end_time);
// }
//
// @Override
// public void valueAxisChanged(final int index, final double lower, final double upper)
// {
// System.out.println("Value axis " + index + ": " + lower + " ... " + upper);
// }
//
// @Override
// public void droppedName(final String name)
// {
// System.out.println("Name dropped: " + name);
// }
//
// @Override
// public void droppedPVName(final ProcessVariable name, final ArchiveDataSource archive)
// {
// System.out.println("PV Name dropped: " + name);
// }
//
// @Override
// public void droppedFilename(final String file_name)
// {
// System.out.println("File Name dropped: " + file_name);
// }
//
// @Override
// public void xyGraphConfigChanged(XYGraph newValue) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void removeAnnotationChanged(Annotation oldValue) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void addAnnotationChanged(Annotation newValue) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void backgroundColorChanged(Color newValue) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void timeAxisForegroundColorChanged(Color oldColor,
// Color newColor) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void valueAxisForegroundColorChanged(int index, Color oldColor,
// Color newColor) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void valueAxisTitleChanged(int index, String oldTitle,
// String newTitle) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void valueAxisAutoScaleChanged(int index, boolean oldAutoScale,
// boolean newAutoScale) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void traceNameChanged(int index, String oldName, String newName) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void traceYAxisChanged(int index, AxisConfig oldConfig,
// AxisConfig config) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void traceTypeChanged(int index, TraceType old,
// TraceType newTraceType) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void traceColorChanged(int index, Color old, Color newColor) {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void valueAxisLogScaleChanged(int index, boolean old,
// boolean logScale) {
// // TODO Auto-generated method stub
//
// }
// };
private void createGUI(final Composite parent) {
final GridLayout layout = new GridLayout(1, false);
parent.setLayout(layout);
ModelBasedPlot plot;
try {
plot = new ModelBasedPlot(true);
} catch (Exception e1) {
e1.printStackTrace();
return;
}
final FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
canvas.setScene(new Scene(plot.getPlot()));
canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
// [Done] button to end demo
final Button ok = new Button(parent, SWT.PUSH);
ok.setText("Done");
ok.setLayoutData(new GridData(SWT.RIGHT, 0, true, false));
ok.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
run = false;
}
});
// plot.addListener(listener);
// Create demo samples
final List<PlotSample> values = new ArrayList<PlotSample>();
for (int i = 1; i < 10; ++i) values.add(new PlotSample("Test", TestHelper.makeValue(i)));
values.add(new PlotSample("Test", TestHelper.makeError(15, "Disconnected")));
// Single value. Line should continue until the following 'disconnect'.
values.add(new PlotSample("Test", TestHelper.makeValue(17)));
values.add(new PlotSample("Test", TestHelper.makeError(18, "Disconnected")));
for (int i = 20; i < 30; ++i) values.add(new PlotSample("Test", TestHelper.makeValue(i)));
final PlotSampleArray samples = new PlotSampleArray();
samples.set(values);
// Add item with demo samples
final ModelItem item = new ModelItem("Demo") {
@Override
public PlotSamples getSamples() {
return samples;
}
@Override
public void write(final PrintWriter writer) {
// NOP
}
};
// TODO: Fix or remove
// item.setColor(new RGB(0, 0, 255));
plot.addTrace(item);
// start_time = VTypeHelper.getTimestamp(samples.getSample(0).getValue());
// end_time = VTypeHelper.getTimestamp(samples.getSample(samples.getSize()-1).getValue());
// plot.setTimeRange(start_time, end_time);
}
use of org.csstudio.trends.databrowser3.model.AxisConfig in project org.csstudio.display.builder by kasemir.
the class AddModelItemCommand method forFormula.
/**
* Create PV via undo-able AddModelItemCommand,
* displaying errors in dialog
* @param shell Shell used for error dialogs
* @param operations_manager OperationsManager where command will be reg'ed
* @param model Model were PV is to be added
* @param axis Axis
* @return AddModelItemCommand or <code>null</code> on error
*/
public static Optional<AddModelItemCommand> forFormula(final Shell shell, final UndoableActionManager operations_manager, final Model model, final String formula_name, final AxisConfig axis) {
// Create item
final FormulaItem item;
try {
// $NON-NLS-1$
item = new FormulaItem(formula_name, "0", new FormulaInput[0]);
axis.setVisible(true);
item.setAxis(axis);
} catch (Exception ex) {
MessageDialog.openError(shell, Messages.Error, NLS.bind(Messages.AddItemErrorFmt, formula_name, ex.getMessage()));
return Optional.empty();
}
// Add to model via undo-able command
return Optional.of(new AddModelItemCommand(shell, operations_manager, model, item));
}
use of org.csstudio.trends.databrowser3.model.AxisConfig in project org.csstudio.display.builder by kasemir.
the class AddModelItemCommand method forPV.
/**
* Create PV via undo-able AddModelItemCommand,
* displaying errors in dialog
* @param shell Shell used for error dialogs
* @param operations_manager OperationsManager where command will be reg'ed
* @param model Model were PV is to be added
* @param pv_name Name of new PV
* @param period scan period
* @param axis Axis
* @param archive Archive data source
* @return AddModelItemCommand or <code>null</code> on error
*/
public static Optional<AddModelItemCommand> forPV(final Shell shell, final UndoableActionManager operations_manager, final Model model, final String pv_name, final double period, final AxisConfig axis, final ArchiveDataSource archive) {
// Create item
final PVItem item;
try {
item = new PVItem(pv_name, period);
if (archive != null)
item.addArchiveDataSource(archive);
else
item.useDefaultArchiveDataSources();
axis.setVisible(true);
item.setAxis(axis);
} catch (Exception ex) {
MessageDialog.openError(shell, Messages.Error, NLS.bind(Messages.AddItemErrorFmt, pv_name, ex.getMessage()));
return Optional.empty();
}
// Add to model via undo-able command
return Optional.of(new AddModelItemCommand(shell, operations_manager, model, item));
}
use of org.csstudio.trends.databrowser3.model.AxisConfig in project org.csstudio.display.builder by kasemir.
the class ControllerBase method createPlotTraces.
/**
* (Re-) create traces in plot for each item in the model
*/
public void createPlotTraces() {
plot.removeAll();
int i = 0;
for (AxisConfig axis : model.getAxes()) plot.updateAxis(i++, axis);
for (ModelItem item : model.getItems()) if (item.isVisible())
plot.addTrace(item);
setAxisFonts();
}
Aggregations