use of net.parostroj.timetable.gui.ini.IniConfig in project grafikon by jub77.
the class FloatingWindowsFactory method createChangesTrackedDialog.
private static FloatingWindow createChangesTrackedDialog(Frame frame, Mediator mediator, ApplicationModel model) {
final ChangesTrackerPanel panel = new ChangesTrackerPanel();
model.addListener(new ApplicationModelListener() {
@Override
public void modelChanged(ApplicationModelEvent event) {
if (event.getType() == ApplicationModelEventType.SET_DIAGRAM_CHANGED)
panel.setTrainDiagram(event.getModel().getDiagram());
}
});
FloatingWindow dialog = new FloatingDialog(frame, panel, "dialog.changestracker.title", "changes.tracker") {
private static final long serialVersionUID = 1L;
@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
IniConfigSection section = super.saveToPreferences(prefs);
section.put("divider", panel.getDividerLocation());
section.put("divider2", panel.getDivider2Location());
return section;
}
@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
IniConfigSection section = super.loadFromPreferences(prefs);
int divider = section.get("divider", Integer.class, panel.getDividerLocation());
panel.setDividerLocation(divider);
divider = section.get("divider2", Integer.class, panel.getDivider2Location());
panel.setDivider2Location(divider);
return section;
}
};
return dialog;
}
use of net.parostroj.timetable.gui.ini.IniConfig in project grafikon by jub77.
the class FloatingWindowsFactory method createCirculationViewDialog.
private static FloatingWindow createCirculationViewDialog(Frame frame, Mediator mediator, ApplicationModel model) {
final CirculationViewPanel panel = new CirculationViewPanel();
mediator.addColleague(new ApplicationGTEventColleague() {
@Override
public void processApplicationEvent(ApplicationModelEvent event) {
if (event.getType() == ApplicationModelEventType.SET_DIAGRAM_CHANGED)
panel.setDiagram(event.getModel().getDiagram());
}
@Override
public void processTrainDiagramEvent(Event event) {
switch(event.getType()) {
case ADDED:
if (event.getObject() instanceof TrainsCycle) {
panel.circulationAdded((TrainsCycle) event.getObject());
} else if (event.getObject() instanceof TrainsCycleType) {
panel.typeAdded((TrainsCycleType) event.getObject());
}
break;
case REMOVED:
if (event.getObject() instanceof TrainsCycle) {
panel.circulationRemoved((TrainsCycle) event.getObject());
} else if (event.getObject() instanceof TrainsCycleType) {
panel.typeRemoved((TrainsCycleType) event.getObject());
}
break;
case ATTRIBUTE:
if (event.getAttributeChange().getName().equals(TrainDiagram.ATTR_FROM_TIME) || event.getAttributeChange().getName().equals(TrainDiagram.ATTR_TO_TIME)) {
panel.timeLimitsUpdated();
}
break;
default:
break;
}
}
@Override
public void processTrainsCycleEvent(Event event) {
panel.circulationUpdated((TrainsCycle) event.getSource());
}
});
FloatingWindow dialog = new FloatingDialog(frame, panel, "dialog.circulationview.title", "circulations.view") {
private static final long serialVersionUID = 1L;
@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
IniConfigSection section = super.saveToPreferences(prefs);
section.put("size", panel.getSizeSlider());
section.put("zoom", panel.getZoomSlider());
section.put("type", panel.getDrawType());
return section;
}
@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
IniConfigSection section = super.loadFromPreferences(prefs);
panel.setSizeSlider(section.get("size", Integer.class, panel.getSizeSlider()));
panel.setZoomSlider(section.get("zoom", Integer.class, panel.getZoomSlider()));
panel.setDrawType(section.get("type", String.class, panel.getDrawType()));
return section;
}
};
return dialog;
}
use of net.parostroj.timetable.gui.ini.IniConfig in project grafikon by jub77.
the class FloatingWindowsFactory method createEventsViewerDialog.
private static FloatingWindow createEventsViewerDialog(final Frame frame, final Mediator mediator, final ApplicationModel model) {
final EventsViewerPanel panel = new EventsViewerPanel();
panel.addConverter(new GTEventTypeConverter());
panel.addConverter(new ApplicationEventTypeConverter());
final FloatingDialog dialog = new FloatingDialog(frame, panel, "dialog.eventsviewer.title", "events.viewer") {
private static final long serialVersionUID = 1L;
@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
IniConfigSection section = super.saveToPreferences(prefs);
section.put("divider", panel.getDividerLocation());
section.put("limit", panel.getLimit());
section.put("show.time", panel.isShowTime());
section.put("write.to.log", panel.isWriteToLog());
return section;
}
@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
IniConfigSection section = super.loadFromPreferences(prefs);
int divider = section.get("divider", Integer.class, panel.getDividerLocation());
panel.setDividerLocation(divider);
int limit = section.get("limit", Integer.class, panel.getLimit());
panel.setLimit(limit);
panel.setShowTime(section.get("show.time", Boolean.class, false));
panel.setWriteToLog(section.get("write.to.log", Boolean.class, false));
return section;
}
};
mediator.addColleague(new AbstractColleague() {
@Override
public void receiveMessage(Object message) {
// do not process messages when the dialog is not visible ...
if (!dialog.isVisible())
return;
panel.addEvent(message);
}
});
return dialog;
}
use of net.parostroj.timetable.gui.ini.IniConfig in project grafikon by jub77.
the class FloatingWindowsFactory method createGTViewDialog.
private static FloatingWindow createGTViewDialog(Frame frame, Mediator mediator, ApplicationModel model) {
final GraphicalTimetableView gtView = new GraphicalTimetableView();
final GTLayeredPane2 scrollPane = new GTLayeredPane2(gtView);
NormalHTS hts = new NormalHTS(model, Color.GREEN, gtView);
gtView.setParameter(GTDraw.HIGHLIGHTED_TRAINS, hts);
gtView.setRegionSelector(hts, TimeInterval.class);
FloatingFrame dialog = new FloatingFrame(frame, scrollPane, "dialog.gtview.title", "gt.view") {
private static final long serialVersionUID = 1L;
@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
IniConfigSection section = super.saveToPreferences(prefs);
section.put("gtv", gtView.getSettings().getStorageString());
return section;
}
@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
IniConfigSection section = super.loadFromPreferences(prefs);
try {
GTViewSettings gtvs = GTViewSettings.parseStorageString(section.get("gtv"));
gtView.setSettings(gtView.getSettings().merge(gtvs));
} catch (Exception e) {
log.warn("Wrong GTView settings - using default values.");
}
return section;
}
};
return dialog;
}
Aggregations