use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class TimeManagement method insertTime.
void insertTime(final Dialog dialog, final JButton appendButton) {
FormattedDate date = getCalendarDate();
final String dateAsString = dateFormat.formatObject(date).toString();
final Window parentWindow;
if (dialog != null) {
parentWindow = (Window) dialog.getParent();
} else {
parentWindow = SwingUtilities.getWindowAncestor(appendButton);
}
final Component mostRecentFocusOwner = parentWindow.getMostRecentFocusOwner();
if (mostRecentFocusOwner instanceof JTextComponent && !(mostRecentFocusOwner.getClass().getName().contains("JSpinField"))) {
final JTextComponent textComponent = (JTextComponent) mostRecentFocusOwner;
textComponent.replaceSelection(dateAsString);
return;
}
if (mostRecentFocusOwner instanceof JTable) {
JTable table = (JTable) mostRecentFocusOwner;
final int[] selectedRows = table.getSelectedRows();
final int[] selectedColumns = table.getSelectedColumns();
for (int r : selectedRows) for (int c : selectedColumns) table.setValueAt(date, r, c);
} else {
ModeController mController = Controller.getCurrentModeController();
for (final NodeModel node : mController.getMapController().getSelectedNodes()) {
final MTextController textController = (MTextController) TextController.getController();
textController.setNodeObject(node, date);
}
}
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class TimeManagement method createDateFormatChooser.
private JComboBox createDateFormatChooser() {
class DateFormatComboBoxElement {
private final PatternFormat dateFormat;
DateFormatComboBoxElement(PatternFormat dateFormat) {
this.dateFormat = dateFormat;
}
PatternFormat getDateFormat() {
return dateFormat;
}
public String toString() {
return dateFormat.formatObject(getCalendarDate()).toString();
}
}
final String dateFormatPattern = ResourceController.getResourceController().getProperty("date_format");
final Vector<DateFormatComboBoxElement> values = new Vector<DateFormatComboBoxElement>();
final List<PatternFormat> datePatterns = FormatController.getController().getDateFormats();
int selectedIndex = 0;
for (int i = 0; i < datePatterns.size(); ++i) {
final PatternFormat patternFormat = datePatterns.get(i);
values.add(new DateFormatComboBoxElement(patternFormat));
if (patternFormat.getPattern().equals(dateFormatPattern)) {
dateFormat = patternFormat;
selectedIndex = i;
}
}
final JComboBox dateFormatChooser = new JComboBox(values);
dateFormatChooser.setFocusable(false);
if (!datePatterns.isEmpty()) {
dateFormatChooser.setSelectedIndex(selectedIndex);
dateFormat = ((DateFormatComboBoxElement) (dateFormatChooser.getSelectedItem())).getDateFormat();
}
dateFormatChooser.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
dateFormat = ((DateFormatComboBoxElement) e.getItem()).getDateFormat();
final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner instanceof JTable) {
JTable table = (JTable) focusOwner;
final int[] selectedRows = table.getSelectedRows();
final int[] selectedColumns = table.getSelectedColumns();
for (int r : selectedRows) for (int c : selectedColumns) {
Object date = table.getValueAt(r, c);
if (date instanceof FormattedDate) {
final FormattedDate fd = (FormattedDate) date;
if (!fd.getDateFormat().equals(dateFormat)) {
table.setValueAt(new FormattedDate(fd, dateFormat.getPattern()), r, c);
}
}
}
} else {
ModeController mController = Controller.getCurrentModeController();
for (final NodeModel node : mController.getMapController().getSelectedNodes()) {
final MTextController textController = (MTextController) TextController.getController();
Object date = node.getUserObject();
if (date instanceof FormattedDate) {
final FormattedDate fd = (FormattedDate) date;
if (!fd.getDateFormat().equals(dateFormat)) {
textController.setNodeObject(node, new FormattedDate(fd, dateFormat.getPattern()));
}
}
}
}
}
});
dateFormatChooser.setAlignmentX(Component.LEFT_ALIGNMENT);
return dateFormatChooser;
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class MainView method updateIcons.
void updateIcons(final NodeView node) {
// setHorizontalTextPosition(node.isLeft() ? SwingConstants.LEADING : SwingConstants.TRAILING);
final MultipleImage iconImages = new MultipleImage();
/* fc, 06.10.2003: images? */
final NodeModel model = node.getModel();
for (final UIIcon icon : IconController.getController().getStateIcons(model)) {
iconImages.addImage(icon.getIcon());
}
final ModeController modeController = getNodeView().getMap().getModeController();
final Collection<MindIcon> icons = IconController.getController(modeController).getIcons(model);
for (final MindIcon myIcon : icons) {
iconImages.addImage(myIcon.getIcon());
}
addOwnIcons(iconImages, model);
setIcon((iconImages.getImageCount() > 0 ? iconImages : null));
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class BubbleMainView method paintComponent.
@Override
public void paintComponent(final Graphics graphics) {
final Graphics2D g = (Graphics2D) graphics;
final NodeView nodeView = getNodeView();
final NodeModel model = nodeView.getModel();
if (model == null) {
return;
}
final ModeController modeController = getNodeView().getMap().getModeController();
final Object renderingHint = modeController.getController().getMapViewManager().setEdgesRenderingHint(g);
paintBackgound(g);
paintDragOver(g);
final Color edgeColor = nodeView.getEdgeColor();
g.setColor(edgeColor);
g.setStroke(BubbleMainView.DEF_STROKE);
g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 10, 10);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, renderingHint);
super.paintComponent(g);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class ArrowIcon method paintIcon.
public void paintIcon(Component c, Graphics g, int x, int y) {
int[] xs = new int[3];
int[] ys = new int[3];
xs[0] = 1 + ARROW_HALF_WIDTH;
xs[1] = 1;
xs[2] = xs[0] + ARROW_HALF_WIDTH;
if (down) {
ys[0] = 1 + ARROW_HEIGTH;
ys[1] = ys[2] = 1;
} else {
ys[0] = 1;
ys[1] = ys[2] = 1 + ARROW_HEIGTH;
}
final Color oldColor = g.getColor();
final Color color = nodeView.getEdgeColor();
g.setColor(color);
Graphics2D g2 = (Graphics2D) g;
final Object renderingHint = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
ModeController modeController = this.nodeView.getMap().getModeController();
modeController.getController().getMapViewManager().setEdgesRenderingHint(g2);
g.drawPolygon(xs, ys, 3);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, renderingHint);
g.setColor(oldColor);
}
Aggregations