Example #1
0
class EditSymbolAttr(JPanel):
    def __init__(self, sattr):
	self.attr = sattr
	self.cbox = JColorChooser(self.attr.color)
	self.sz_field = JTextField(str(self.attr.size))
	szpanel = JPanel()
	szpanel.add(self.sz_field)
	szpanel.setBorder(BorderFactory.createTitledBorder("symbol size (integer)"))
	self.filled_box = JCheckBox("Filled ?:",self.attr.filled)
	self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
	self.shape_cbox.setSelectedItem(self.attr.shape)
	self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
	panel1 = JPanel()
	panel1.setLayout(BorderLayout())
	panel1.add(szpanel,BorderLayout.NORTH)
	panel2 = JPanel()
	panel2.setLayout(GridLayout(1,2))
	panel2.add(self.shape_cbox)
	panel2.add(self.filled_box)
	panel1.add(panel2,BorderLayout.SOUTH)
	self.setLayout(BorderLayout())
	self.add(self.cbox,BorderLayout.CENTER)
	self.add(panel1,BorderLayout.SOUTH)
    def setAttribute(self,sattr):
	self.attr = sattr
	self.cbox.color = self.attr.color
	self.sz_field.text = str(self.attr.size)
	self.shape_cbox.setSelectedItem(self.attr.shape)
    def update(self):
	self.attr.color = self.cbox.getColor()
	self.attr.size = string.atoi(self.sz_field.getText())
	self.attr.filled = self.filled_box.isSelected()
	self.attr.shape = self.shape_cbox.getSelectedItem()
	self.attr.sym = self.attr.createSymbol()
Example #2
0
class EditCurveAttr(JPanel):
    def __init__(self, cattr):
        self.attr = cattr
        self.cbox = JColorChooser(self.attr.color)
        self.sym_panel = EditSymbolAttr(cattr.sym_prop)
        self.thickness_field = JTextField(str(cattr.thickness), 2)
        self.draw_symbol_box = JCheckBox("Draw Symbol?", cattr.draw_symbol)
        self.dps_field = JTextField(str(self.attr.data_per_symbol), 2)
        self.dash_box = JComboBox(CurveProps.DASH_TYPES.keys())
        self.dash_box.setSelectedItem(self.attr.dash_type)
        self.dash_box.setBorder(
            BorderFactory.createTitledBorder("Dash type: (Only JDK2 & Slow!)"))
        tpanelx = JPanel()
        tpanelx.add(self.thickness_field)
        tpanelx.setBorder(
            BorderFactory.createTitledBorder("curve thickness (integer)"))
        tpanely = JPanel()
        tpanely.add(self.dps_field)
        tpanely.setBorder(
            BorderFactory.createTitledBorder("data per symbol(integer)"))
        tpanel = JPanel()
        tpanel.setLayout(GridLayout(2, 2))
        tpanel.add(self.draw_symbol_box)
        tpanel.add(tpanelx)
        tpanel.add(tpanely)
        tpanel.add(self.dash_box)
        panel1 = JPanel()
        panel1.setLayout(BorderLayout())
        panel1.add(self.cbox, BorderLayout.CENTER)
        panel1.add(tpanel, BorderLayout.SOUTH)
        panel2 = JPanel()
        panel2.setLayout(BorderLayout())
        panel2.add(self.sym_panel, BorderLayout.CENTER)
        tp1 = JTabbedPane()
        tp1.addTab("Curve Attributes", panel1)
        tp1.addTab("Symbol Attributes", panel2)
        tp1.setSelectedComponent(panel1)
        self.setLayout(BorderLayout())
        self.add(tp1, BorderLayout.CENTER)

    def setAttribute(self, cattr):
        self.attr = cattr
        self.cbox.color = self.attr.color
        self.sym_panel.setAttribute(cattr.sym_prop)
        self.thickness_field.text = str(cattr.thickness)
        self.dps_field.text = str(cattr.data_per_symbol)
        self.draw_symbol_box.setSelected(cattr.draw_symbol)
        self.dash_box.setSelectedItem(cattr.dash_type)

    def update(self):
        self.attr.color = self.cbox.getColor()
        self.attr.thickness = string.atoi(self.thickness_field.text)
        self.attr.data_per_symbol = string.atoi(self.dps_field.text)
        self.attr.draw_symbol = self.draw_symbol_box.isSelected()
        self.attr.dash_type = self.dash_box.getSelectedItem()
        #print 'Updating Self.draw_symbol',self.draw_symbol,self.attr
        self.sym_panel.update()
Example #3
0
class CurveDialog(JDialog):
    def __init__(self, cattrs):
        #JDialog.__init__(self,"Curve Attribute Editor")
        #("Curve Attribute Editor")
        if cattrs == None or len(cattrs) == 0:
            raise "No curve attributes specified"
        self.attrs = cattrs
        self.cpanel = EditCurveAttr(cattrs[0])
        pane = self.getContentPane()
        pane.setLayout(BorderLayout())
        x = map(lambda x: x + 1, range(len(self.attrs)))
        self.curveBox = JComboBox(x)
        self.curveBox.setBorder(BorderFactory.createTitledBorder("Curve #"))
        self.curveBox.setSelectedItem(0)

        class CListener(ItemListener):
            def __init__(self, cbox, cpanel, cattrs):
                self.cbox = cbox
                self.cpanel = cpanel
                self.attrs = cattrs

            def itemStateChanged(self, evt):
                crvNo = self.cbox.getSelectedItem()
                self.cpanel.update()
                self.cpanel.setAttribute(self.attrs[crvNo - 1])

        self.curveBox.addItemListener(
            CListener(self.curveBox, self.cpanel, self.attrs))
        okBtn = JButton("OK", actionPerformed=self.ok_action)
        cancelBtn = JButton("Cancel", actionPerformed=self.cancel_action)
        btnPanel = JPanel()
        btnPanel.setLayout(GridLayout(1, 3))
        btnPanel.add(self.curveBox)
        btnPanel.add(okBtn)
        btnPanel.add(cancelBtn)
        pane.add(self.cpanel, BorderLayout.CENTER)
        pane.add(btnPanel, BorderLayout.SOUTH)
        self.setLocation(100, 100)
        self.pack()
        self.setVisible(1)

    def ok_action(self, evt):
        #crvNo = self.curveBox.getSelectedItem()
        #print 'Setting attributes for ', crvNo
        #print self.attrs[crvNo-1]
        self.cpanel.update()
        self.cancel_action(evt)

    def cancel_action(self, evt):
        self.dispose()
Example #4
0
class EditCurveAttr(JPanel):
    def __init__(self, cattr):
	self.attr = cattr
	self.cbox = JColorChooser(self.attr.color)
	self.sym_panel = EditSymbolAttr(cattr.sym_prop)
	self.thickness_field = JTextField(str(cattr.thickness),2)
	self.draw_symbol_box = JCheckBox("Draw Symbol?",cattr.draw_symbol)
	self.dps_field = JTextField(str(self.attr.data_per_symbol),2)
	self.dash_box = JComboBox(CurveProps.DASH_TYPES.keys())
	self.dash_box.setSelectedItem(self.attr.dash_type)
	self.dash_box.setBorder(BorderFactory.createTitledBorder("Dash type: (Only JDK2 & Slow!)"))
	tpanelx = JPanel()
	tpanelx.add(self.thickness_field)
	tpanelx.setBorder(BorderFactory.createTitledBorder("curve thickness (integer)"))
	tpanely = JPanel()
	tpanely.add(self.dps_field)
	tpanely.setBorder(BorderFactory.createTitledBorder("data per symbol(integer)"))
	tpanel = JPanel();tpanel.setLayout(GridLayout(2,2));
	tpanel.add(self.draw_symbol_box); tpanel.add(tpanelx);
	tpanel.add(tpanely); tpanel.add(self.dash_box);
	panel1 = JPanel()
	panel1.setLayout(BorderLayout())
	panel1.add(self.cbox,BorderLayout.CENTER)
	panel1.add(tpanel, BorderLayout.SOUTH)
	panel2 = JPanel()
	panel2.setLayout(BorderLayout())
	panel2.add(self.sym_panel,BorderLayout.CENTER)
	tp1 = JTabbedPane()
	tp1.addTab("Curve Attributes",panel1)
	tp1.addTab("Symbol Attributes",panel2)
	tp1.setSelectedComponent(panel1)
	self.setLayout(BorderLayout())
	self.add(tp1,BorderLayout.CENTER)
    def setAttribute(self,cattr):
	self.attr = cattr
	self.cbox.color = self.attr.color
	self.sym_panel.setAttribute(cattr.sym_prop)
	self.thickness_field.text = str(cattr.thickness)
	self.dps_field.text = str(cattr.data_per_symbol)
	self.draw_symbol_box.setSelected(cattr.draw_symbol)
	self.dash_box.setSelectedItem(cattr.dash_type)
    def update(self):
	self.attr.color = self.cbox.getColor()
	self.attr.thickness = string.atoi(self.thickness_field.text)
	self.attr.data_per_symbol = string.atoi(self.dps_field.text)
	self.attr.draw_symbol = self.draw_symbol_box.isSelected()
	self.attr.dash_type = self.dash_box.getSelectedItem()
	#print 'Updating Self.draw_symbol',self.draw_symbol,self.attr
	self.sym_panel.update()
Example #5
0
class CurveDialog(JDialog):
    def __init__(self, cattrs):
	#JDialog.__init__(self,"Curve Attribute Editor")
	#("Curve Attribute Editor")
	if cattrs == None or len(cattrs) == 0:
	    raise "No curve attributes specified"
	self.attrs = cattrs
	self.cpanel = EditCurveAttr(cattrs[0])
	pane = self.getContentPane()
	pane.setLayout(BorderLayout())
	x = map(lambda x: x+1,range(len(self.attrs)))
	self.curveBox = JComboBox(x)
	self.curveBox.setBorder(BorderFactory.createTitledBorder("Curve #"))
	self.curveBox.setSelectedItem(0)
	class CListener(ItemListener):
	    def __init__(self,cbox,cpanel,cattrs):
		self.cbox = cbox
		self.cpanel = cpanel
		self.attrs = cattrs
	    def itemStateChanged(self, evt):
		crvNo = self.cbox.getSelectedItem()
		self.cpanel.update()
		self.cpanel.setAttribute(self.attrs[crvNo-1])
	self.curveBox.addItemListener(CListener(self.curveBox, self.cpanel,self.attrs))
	okBtn = JButton("OK",actionPerformed=self.ok_action)
	cancelBtn = JButton("Cancel",actionPerformed=self.cancel_action)
	btnPanel = JPanel()
	btnPanel.setLayout(GridLayout(1,3))
	btnPanel.add(self.curveBox)
	btnPanel.add(okBtn)
	btnPanel.add(cancelBtn)
	pane.add(self.cpanel,BorderLayout.CENTER)
	pane.add(btnPanel, BorderLayout.SOUTH)
	self.setLocation(100,100)
	self.pack()
	self.setVisible(1)
    def ok_action(self,evt):
	#crvNo = self.curveBox.getSelectedItem()
	#print 'Setting attributes for ', crvNo
	#print self.attrs[crvNo-1]
	self.cpanel.update()
	self.cancel_action(evt)
    def cancel_action(self,evt):
	self.dispose()
Example #6
0
class EditSymbolAttr(JPanel):
    def __init__(self, sattr):
        self.attr = sattr
        self.cbox = JColorChooser(self.attr.color)
        self.sz_field = JTextField(str(self.attr.size))
        szpanel = JPanel()
        szpanel.add(self.sz_field)
        szpanel.setBorder(
            BorderFactory.createTitledBorder("symbol size (integer)"))
        self.filled_box = JCheckBox("Filled ?:", self.attr.filled)
        self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
        self.shape_cbox.setSelectedItem(self.attr.shape)
        self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
        panel1 = JPanel()
        panel1.setLayout(BorderLayout())
        panel1.add(szpanel, BorderLayout.NORTH)
        panel2 = JPanel()
        panel2.setLayout(GridLayout(1, 2))
        panel2.add(self.shape_cbox)
        panel2.add(self.filled_box)
        panel1.add(panel2, BorderLayout.SOUTH)
        self.setLayout(BorderLayout())
        self.add(self.cbox, BorderLayout.CENTER)
        self.add(panel1, BorderLayout.SOUTH)

    def setAttribute(self, sattr):
        self.attr = sattr
        self.cbox.color = self.attr.color
        self.sz_field.text = str(self.attr.size)
        self.shape_cbox.setSelectedItem(self.attr.shape)

    def update(self):
        self.attr.color = self.cbox.getColor()
        self.attr.size = string.atoi(self.sz_field.getText())
        self.attr.filled = self.filled_box.isSelected()
        self.attr.shape = self.shape_cbox.getSelectedItem()
        self.attr.sym = self.attr.createSymbol()