use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class AttributeTable method updateComponentFontAndColors.
private void updateComponentFontAndColors(final JComponent c) {
final NodeView nodeView = attributeView.getNodeView();
final MapView mapView = nodeView.getMap();
final ModeController modeController = mapView.getModeController();
final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
final Font font = style.getFont(attributeStyleNode);
c.setFont(font.deriveFont(UITools.FONT_SCALE_FACTOR * font.getSize2D()));
if (!SwingUtilities.isDescendingFrom(this, nodeView)) {
return;
}
final Color backgroundColor = NodeStyleModel.getBackgroundColor(attributeStyleNode);
if (backgroundColor != null) {
c.setOpaque(true);
c.setBackground(backgroundColor);
} else {
c.setBackground(nodeView.getBackgroundColor());
c.setOpaque(false);
}
c.setForeground(style.getColor(attributeStyleNode));
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class AttributeTable method updateGridColor.
private void updateGridColor() {
final NodeView nodeView = attributeView.getNodeView();
if (!SwingUtilities.isDescendingFrom(this, nodeView))
return;
final MapView mapView = nodeView.getMap();
final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
final EdgeModel edge = EdgeModel.getModel(attributeStyleNode);
if (edge != null) {
final Color edgeColor = edge.getColor();
setGridAndBorderColor(edgeColor);
} else
this.gridColor = null;
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class MNodeDropListener method isFromDescencantNode.
private boolean isFromDescencantNode(final DropTargetDropEvent event) {
final Transferable t = event.getTransferable();
final List<NodeModel> transferData;
try {
transferData = getNodeObjects(t);
} catch (Exception e) {
return false;
}
final NodeModel node = ((MainView) event.getDropTargetContext().getComponent()).getNodeView().getModel();
for (final NodeModel selected : transferData) {
if ((node == selected) || node.isDescendantOf(selected))
return true;
}
return false;
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class MNodeDropListener method isFromSameMap.
private boolean isFromSameMap(final DropTargetDropEvent event) {
final Transferable t = event.getTransferable();
final List<NodeModel> transferData;
try {
transferData = getNodeObjects(t);
} catch (Exception e) {
return false;
}
final NodeModel node = ((MainView) event.getDropTargetContext().getComponent()).getNodeView().getModel();
for (final NodeModel selected : transferData) {
if (selected.getMap() != node.getMap())
return false;
}
return true;
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class MNodeMotionListener method calculateNewFreeNodeIndex.
private int calculateNewFreeNodeIndex(final NodeView nodeV) {
final NodeModel node = nodeV.getModel();
if (SummaryNode.isHidden(node))
return -1;
final boolean left = nodeV.isLeft();
final int nodeY = getRefY(nodeV);
final NodeView parent = nodeV.getParentView();
int newIndex = 0;
int oldIndex = -1;
int wrondSideCount = 0;
int hiddenNodeCount = 0;
final int childCount = node.getParentNode().getChildCount();
for (int i = 0; i < childCount; i++) {
final Component component = parent.getComponent(i);
if (!(component instanceof NodeView))
continue;
NodeView siblingV = (NodeView) component;
final NodeModel sibling = siblingV.getModel();
if (siblingV.isLeft() == left && !SummaryNode.isHidden(sibling) && getRefY(siblingV) > nodeY)
break;
else {
if (siblingV != nodeV) {
newIndex++;
if (siblingV.isLeft() != left)
wrondSideCount++;
else {
wrondSideCount = 0;
if (oldIndex >= 0 && SummaryNode.isHidden(sibling))
hiddenNodeCount++;
else
hiddenNodeCount = 0;
}
} else {
oldIndex = i;
}
}
}
final int result = newIndex - wrondSideCount - hiddenNodeCount;
if (result == oldIndex)
return -1;
return result;
}
Aggregations