Package org.freeplane.features.styles

Examples of org.freeplane.features.styles.MapStyleModel


public class DefaultStyleRenderer implements TableCellRenderer {
  private TableCellRenderer renderer = new DefaultTableCellRenderer();
  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
                                                 int row, int column) {
    final MapStyleModel styles = ((ConditionalStyleTable)table).getStyles();
    final NodeModel styleNode = styles.getStyleNode((IStyle)value);
    if (styleNode == null){
      value = MapStyleModel.DEFAULT_STYLE;
    }
    return renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  }
View Full Code Here


    }
    final Controller controller = Controller.getCurrentController();
    final NodeModel selectedNode = controller.getSelection().getSelected();

    final MapModel map = controller.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final MapModel styleMap = styleModel.getStyleMap();
    final IStyle newStyle = StyleFactory.create(styleName);
    if (null != styleModel.getStyleNode(newStyle)) {
      UITools.errorMessage(TextUtils.getText("style_already_exists"));
      return;
    }
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel newNode = new NodeModel(styleMap);
    newNode.setUserObject(newStyle);
    final LogicalStyleController styleController = LogicalStyleController.getController();
    final ArrayList<IStyle> styles = new ArrayList<IStyle>(styleController.getStyles(selectedNode));
    for(int i = styles.size() - 1; i >= 0; i--){
      IStyle style = styles.get(i);
      if(MapStyleModel.DEFAULT_STYLE.equals(style)){
        continue;
      }
      final NodeModel styleNode = styleModel.getStyleNode(style);
            if(styleNode == null){
                continue;
            }
      Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, styleNode, newNode);
    }
    Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
    Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
    NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(styleMap, MapStyleModel.STYLES_USER_DEFINED);
    if(userStyleParentNode == null){
      userStyleParentNode = new NodeModel(styleMap);
      userStyleParentNode.setUserObject(new StyleNamedObject(MapStyleModel.STYLES_USER_DEFINED));
      mapController.insertNode(userStyleParentNode, styleMap.getRootNode(), false, false, true);

    }
    mapController.insertNode(newNode, userStyleParentNode, false, false, true);
    mapController.select(newNode);
    final IActor actor = new IActor() {
      public void undo() {
        styleModel.removeStyleNode(newNode);
        styleController.refreshMap(map);
      }

      public String getDescription() {
        return "NewStyle";
      }

      public void act() {
        styleModel.addStyleNode(newNode);
        styleController.refreshMap(map);
      }
    };
    Controller.getCurrentModeController().execute(actor, styleMap);
  }
View Full Code Here

  abstract public ConditionalStyleModel getConditionalStyleModel();

  protected Component createConditionalStylePane(final MapModel map, final ConditionalStyleModel conditionalStyleModel) {
    final JPanel pane = new JPanel(new BorderLayout());
      final MapStyleModel styles = MapStyleModel.getExtension(map);
    final TableModel tableModel = MLogicalStyleController.getController().getConditionalStyleModelAsTableModel(map, conditionalStyleModel);
    final ConditionalStyleTable conditionalStyleTable = new ConditionalStyleTable(styles, tableModel);
    if(conditionalStyleTable.getRowCount() > 0){
      conditionalStyleTable.setRowSelectionInterval(0, 0);
    }
View Full Code Here

  public IPropertyHandler<Integer, NodeModel> removeWidthGetter(final Integer key) {
    return widthHandlers.removeGetter(key);
  }

  private Color getStyleEdgeColor(final MapModel map, final Collection<IStyle> collection) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for(IStyle styleKey : collection){
      final NodeModel styleNode = model.getStyleNode(styleKey);
      if (styleNode == null) {
        continue;
      }
      final EdgeModel styleModel = EdgeModel.getModel(styleNode);
      if (styleModel == null) {
View Full Code Here

    }
    return null;
  }

  private Integer getStyleWidth(final MapModel map, final Collection<IStyle> collection) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for(IStyle styleKey : collection){
      final NodeModel styleNode = model.getStyleNode(styleKey);
      if (styleNode == null) {
        continue;
      }
      final EdgeModel styleModel = EdgeModel.getModel(styleNode);
      if (styleModel == null) {
View Full Code Here

    }
    return null;
  }

  private EdgeStyle getStyleStyle(final MapModel map, final Collection<IStyle> collection) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for(IStyle styleKey : collection){
      final NodeModel styleNode = model.getStyleNode(styleKey);
      if (styleNode == null) {
        continue;
      }
      final EdgeModel styleModel = EdgeModel.getModel(styleNode);
      if (styleModel == null) {
View Full Code Here

  }

  public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    MapStyle mapStyle = (MapStyle) controller.getModeController().getExtension(MapStyle.class);
    final MapStyleModel model = (MapStyleModel) mapStyle.getMapHook();
    final Color oldBackgroundColor;
    final String colorPropertyString = ResourceController.getResourceController().getProperty(
        MapStyle.RESOURCES_BACKGROUND_COLOR);
    final Color defaultBgColor = ColorUtils.stringToColor(colorPropertyString);
    if (model != null) {
      oldBackgroundColor = model.getBackgroundColor();
    }
    else {
      oldBackgroundColor = defaultBgColor;
    }
    final Color actionColor = ColorTracker.showCommonJColorChooserDialog(controller.getSelection()
View Full Code Here

  @Override
  public ConditionalStyleModel getConditionalStyleModel() {
    final Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
      final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final ConditionalStyleModel conditionalStyleModel = styleModel.getConditionalStyleModel();
      return conditionalStyleModel;
    }
View Full Code Here

  }

  public void actionPerformed(final ActionEvent e) {
    final NodeModel node = Controller.getCurrentController().getSelection().getSelected();
    final IStyle style = LogicalStyleController.getController().getFirstStyle(node);
    final MapStyleModel extension = MapStyleModel.getExtension(node.getMap());
    final NodeModel styleNode = extension.getStyleNode(style);
    if(styleNode == null)
      return;
    Controller.getCurrentModeController().undoableCopyExtensions(LogicalStyleKeys.NODE_STYLE, node, styleNode);
    Controller.getCurrentModeController().undoableRemoveExtensions(LogicalStyleKeys.NODE_STYLE, node, node);
    LogicalStyleController.getController().refreshMap(node.getMap());
View Full Code Here

  public void setName(String styleName) {
    if (styleName == null) {
      setStyle(null);
    }
    else {
      final MapStyleModel mapStyleModel = MapStyleModel.getExtension(getDelegate().getMap());
      // actually styles is a HashSet so lookup is fast
      final Set<IStyle> styles = mapStyleModel.getStyles();
      // search for user defined styles
      final IStyle styleString = StyleFactory.create(styleName);
      if (styles.contains(styleString)) {
        setStyle(styleString);
        return;
View Full Code Here

TOP

Related Classes of org.freeplane.features.styles.MapStyleModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.