1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2013 - Marcos CARDINOT 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 * 14 */ 15 package org.scilab.modules.gui.ged.graphic_objects.rectangle; 16 17 import javax.swing.JPanel; 18 import org.scilab.modules.graphic_objects.graphicController.GraphicController; 19 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties; 20 import org.scilab.modules.gui.ged.MessagesGED; 21 import org.scilab.modules.gui.ged.graphic_objects.SimpleSection; 22 import org.scilab.modules.gui.ged.graphic_objects.properties.ContouredObject; 23 24 /** 25 * Construction and startup of all components of the section: Style/Appeareance. 26 * 27 * @author Marcos CARDINOT <mcardinot@gmail.com> 28 */ 29 public class Style extends SimpleSection { 30 private JPanel sectionPanel; 31 private static Style instance; 32 private ContouredObject contouredObject = new ContouredObject(); 33 34 /** 35 * Receives and passes the objectID to the parent class. 36 * @param objectID Enters the identification of object. 37 */ Style(Integer objectID)38 public Style(Integer objectID) { 39 super(MessagesGED.style_appearance, "rectangle"); 40 instance = this; 41 sectionPanel = getSectionPanel(); 42 initComponents(objectID); 43 } 44 45 /** 46 * Get instance 47 * @return instance 48 */ getInstance()49 public static Style getInstance() { 50 return instance; 51 } 52 53 /** 54 * Add all the properties in this section. 55 * @param objectID uid 56 */ 57 @Override initComponents(Integer objectID)58 public final void initComponents(Integer objectID) { 59 int row = 0; 60 final int leftmargin = 16; //to inner components 61 int column = 0; //first column 62 63 Integer parentFigure = (Integer) GraphicController.getController() 64 .getProperty(objectID, GraphicObjectProperties.__GO_PARENT_FIGURE__); 65 66 //Components of the property: Fill Mode 67 contouredObject.fillMode(sectionPanel, row++, column, leftmargin, objectID); 68 69 //Components of the property: Background 70 contouredObject.backgroundColor(sectionPanel, row++, column, leftmargin, objectID, parentFigure); 71 72 //Components of the property: Line Mode 73 contouredObject.lineMode(sectionPanel, row++, column, leftmargin, objectID); 74 75 //Components of the property: Line Style 76 contouredObject.lineStyle(sectionPanel, row++, column, leftmargin, objectID); 77 78 //Components of the property: Foreground 79 contouredObject.lineColor(sectionPanel, row++, column, leftmargin, 80 objectID, parentFigure, "rectangle.Style", this); 81 82 //Components of the property: Thickness 83 contouredObject.thickness(sectionPanel, row++, column, leftmargin, objectID); 84 } 85 86 /** 87 * Change the color of the object. 88 * @param scilabColor index of the color map. 89 * @param UID objectID. 90 */ setForegroundColor(int scilabColor, Integer UID)91 public void setForegroundColor(int scilabColor, Integer UID) { 92 GraphicController.getController().setProperty( 93 UID, GraphicObjectProperties.__GO_LINE_COLOR__, scilabColor); 94 } 95 }