use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeView method getCoordinates.
private void getCoordinates(final LinkedList<Point> inList, int additionalDistanceForConvexHull, final boolean byChildren, final int transX, final int transY) {
if (!isVisible()) {
return;
}
if (isContentVisible()) {
if (byChildren) {
final ModeController modeController = getMap().getModeController();
final CloudController cloudController = CloudController.getController(modeController);
final CloudModel cloud = cloudController.getCloud(getModel());
if (cloud != null) {
additionalDistanceForConvexHull += CloudView.getAdditionalHeigth(cloud, this) / 5;
}
}
final int x = transX + getContent().getX() - getDeltaX();
final int y = transY + getContent().getY() - getDeltaY();
final int width = mainView.getMainViewWidthWithFoldingMark();
final int heightWithFoldingMark = mainView.getMainViewHeightWithFoldingMark();
final int height = Math.max(heightWithFoldingMark, getContent().getHeight());
inList.addLast(new Point(-additionalDistanceForConvexHull + x, -additionalDistanceForConvexHull + y));
inList.addLast(new Point(-additionalDistanceForConvexHull + x, additionalDistanceForConvexHull + y + height));
inList.addLast(new Point(additionalDistanceForConvexHull + x + width, additionalDistanceForConvexHull + y + height));
inList.addLast(new Point(additionalDistanceForConvexHull + x + width, -additionalDistanceForConvexHull + y));
}
for (final NodeView child : getChildrenViews()) {
child.getCoordinates(inList, additionalDistanceForConvexHull, true, transX + child.getX(), transY + child.getY());
}
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeView method getEdgeColor.
public Color getEdgeColor() {
if (edgeColor.hasValue())
return edgeColor.getValue();
Rules rule = edgeColor.getRule();
if (rule == EdgeController.Rules.BY_COLUMN) {
final Color color = new AutomaticEdgeStyle(this).getColor();
edgeColor.setCache(color);
return color;
}
final NodeModel parentNode = model.getParentNode();
if (rule == EdgeController.Rules.BY_BRANCH && parentNode.isRoot() || rule == EdgeController.Rules.BY_LEVEL) {
final int index;
if (rule == EdgeController.Rules.BY_BRANCH)
index = parentNode.getIndex(model) + 1;
else
index = model.getNodeLevel(false) + (model.isHiddenSummary() ? 1 : 0);
final MapModel mapModel = map.getModel();
ModeController modeController = map.getModeController();
EdgeController edgeController = modeController.getExtension(EdgeController.class);
if (edgeController.areEdgeColorsAvailable(mapModel)) {
Color color = edgeController.getEdgeColor(mapModel, index);
edgeColor.setCache(color);
return color;
}
} else if (rule == EdgeController.Rules.BY_PARENT) {
final NodeView parentView = getParentView();
if (parentView != null) {
final Color color = parentView.getEdgeColor();
return color;
}
}
return Color.GRAY;
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeViewFactory method newMainView.
MainView newMainView(final NodeView node) {
ShapeConfigurationModel shapeConfiguration = shapeConfiguration(node);
final MainView oldView = node.getMainView();
if (oldView != null && oldView.getShapeConfiguration().equals(shapeConfiguration))
return oldView;
final ModeController modeController = node.getMap().getModeController();
final MainView view;
switch(shapeConfiguration.getShape()) {
case fork:
view = new ForkMainView();
break;
case bubble:
view = new BubbleMainView(shapeConfiguration);
break;
case oval:
view = new OvalMainView(shapeConfiguration);
break;
case rectangle:
view = new RectangleMainView(shapeConfiguration);
break;
case wide_hexagon:
view = new WideHexagonMainView(shapeConfiguration);
break;
case narrow_hexagon:
view = new NarrowHexagonMainView(shapeConfiguration);
break;
default:
System.err.println("Tried to create a NodeView of unknown Style " + String.valueOf(shapeConfiguration.getShape()));
view = new ForkMainView();
}
NodeTooltipManager toolTipManager = NodeTooltipManager.getSharedInstance(modeController);
toolTipManager.registerComponent(view);
return view;
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeViewFactory method shapeConfiguration.
private ShapeConfigurationModel shapeConfiguration(NodeView node) {
final ModeController modeController = node.getMap().getModeController();
final NodeModel model = node.getModel();
ShapeConfigurationModel shapeConfiguration = NodeStyleController.getController(modeController).getShapeConfiguration(model);
if (shapeConfiguration.getShape().equals(NodeStyleModel.Shape.combined)) {
if (node.isFolded()) {
shapeConfiguration = shapeConfiguration.withShape(NodeStyleModel.Shape.bubble);
} else {
shapeConfiguration = ShapeConfigurationModel.FORK;
}
} else
while (shapeConfiguration.getShape().equals(NodeStyleModel.Shape.as_parent)) {
NodeView parent = node.getParentView();
if (parent == null)
shapeConfiguration = ShapeConfigurationModel.DEFAULT_ROOT_OVAL;
else if (parent.getParentView() == null)
shapeConfiguration = ShapeConfigurationModel.FORK;
else
shapeConfiguration = parent.getMainView().getShapeConfiguration();
}
return shapeConfiguration;
}
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)) {
selectedIndex = i;
}
}
if (!datePatterns.isEmpty()) {
dateFormat = datePatterns.get(selectedIndex);
}
final JComboBox dateFormatChooser = new JComboBoxWithBorder(values);
dateFormatChooser.setFocusable(false);
if (!datePatterns.isEmpty()) {
dateFormatChooser.setSelectedIndex(selectedIndex);
}
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;
}
Aggregations