def getfont(fontdic, **kwargs): basefont = kwargs.pop('basefont', None) if basefont is None: name = 'Arial' size = 14 bold = False italic = False else: name = basefont.getName() size = basefont.getSize() bold = basefont.isBold() italic = basefont.isItalic() name = fontdic.pop('name', name) size = fontdic.pop('size', size) bold = fontdic.pop('bold', bold) italic = fontdic.pop('italic', italic) if bold: if italic: font = Font(name, Font.BOLD | Font.ITALIC, size) else: font = Font(name, Font.BOLD, size) else: if italic: font = Font(name, Font.ITALIC, size) else: font = Font(name, Font.PLAIN, size) return font
def __init__(self, *args, **kwargs): axes = kwargs.pop('axes', None) self._set_plot(axes) figure = kwargs.pop('figure', None) self.figure = figure if len(args) > 0: position = args[0] else: position = kwargs.pop('position', None) outerposition = kwargs.pop('outerposition', None) if position is None: position = [0.13, 0.11, 0.71, 0.815] self.active_outerposition(True) else: self.active_outerposition(False) self.set_position(position) if not outerposition is None: self.set_outerposition(outerposition) self.active_outerposition(True) units = kwargs.pop('units', None) if not units is None: self.axes.setUnits(units) tickfontname = kwargs.pop('tickfontname', 'Arial') tickfontsize = kwargs.pop('tickfontsize', 14) tickbold = kwargs.pop('tickbold', False) if tickbold: font = Font(tickfontname, Font.BOLD, tickfontsize) else: font = Font(tickfontname, Font.PLAIN, tickfontsize) self.axes.setAxisTickFont(font) antialias = kwargs.pop('antialias', None) if not antialias is None: self.axes.setAntialias(antialias)
def createMainWindow(): # Create window frame = JFrame('Epiphany Core Visualisation', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(660, 675)) # Main layout mainLayout = JPanel() frame.add(mainLayout) # Title #title = JLabel('hello', JLabel.CENTER) #mainLayout.add(title) # Cores corepanel = JPanel(GridLayout(8, 8)) global cores cores = [] for i in range(0, 64): core = JPanel(GridLayout(2, 1)) core.setPreferredSize(Dimension(80, 80)) corename = '(' + str(i % 8) + ',' + str(i / 8) + ')' namelabel = JLabel(corename, JLabel.CENTER) namelabel.setFont(Font("Dialog", Font.PLAIN, 18)) portname = str(i + MINPORT) portlabel = JLabel(portname, JLabel.CENTER) portlabel.setFont(Font("Dialog", Font.PLAIN, 16)) core.add(namelabel) core.add(portlabel) core.setBackground(Color.BLACK) corepanel.add(core) cores.append(core) mainLayout.add(corepanel) frame.visible = True
def notifyCurrentDevices(): global mainScreenImg global mainScreen global connectedDevices g = mainScreenImg.createGraphics() g.setFont(Font("Monospaced", Font.BOLD, 13)) g.drawString("[Detected devices]", 70, 100) g.setColor(Color.BLACK) g.fillRect(70, 100, REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN) g.setFont(Font("Monospaced", Font.PLAIN, 13)) g.setColor(Color.GRAY) g.setBackground(Color.BLACK) for device in connectedDevices: text = "%s(%s)" % (device.productName, device.serialno) if device.focused: g.setColor(Color.WHITE) text = "Focused : " + text g.drawString(text, 70, 100 + 30*(connectedDevices.index(device)+1)) if device.focused: g.setColor(Color.GRAY) mainScreen.setIcon(swing.ImageIcon(mainScreenImg))
def __init__(self, width, height, range): JPanel() plot = MeterPlot(DefaultValueDataset(0)) self.plot = plot self.setRange(range) #plot.addInterval(MeterInterval("Normal", Range(0.0, 35.0), # Color.lightGray, BasicStroke(2.0), # Color(0, 255, 0, 64))) #plot.addInterval(MeterInterval("Warning", Range(35.0, 50.0), # Color.lightGray, BasicStroke(2.0), Color(255, 255, 0, 64))) #plot.addInterval(MeterInterval("Critical", Range(50.0, 60.0), # Color.lightGray, BasicStroke(2.0), # Color(255, 0, 0, 128))) plot.setNeedlePaint(Color.darkGray) plot.setDialBackgroundPaint(Color.white) plot.setDialOutlinePaint(Color.white) plot.setDialShape(DialShape.CHORD) plot.setMeterAngle(260) plot.setTickLabelsVisible(True) plot.setTickLabelFont(Font("Dialog", Font.BOLD, 10)) plot.setTickLabelPaint(Color.darkGray) plot.setTickSize(5.0) plot.setTickPaint(Color.lightGray) plot.setValuePaint(Color.black) plot.setValueFont(Font("Dialog", Font.BOLD, 14)) plot.setUnits("k sims") chart = JFreeChart("Simulations computed", JFreeChart.DEFAULT_TITLE_FONT, plot, False) self.chart = chart chart.setBackgroundPaint(Color.white) cp = ChartPanel(chart) cp.setPreferredSize(Dimension(width, height)) self.add(cp)
def __set_axes3d(self, ax, **kwargs): """ Set an axes. :param aspect: (*string*) ['equal' | 'auto'] or a number. If a number the ratio of x-unit/y-unit in screen-space. Default is 'auto'. :param bgcolor: (*Color*) Optional, axes background color. :param axis: (*boolean*) Optional, set all axis visible or not. Default is ``True`` . :param bottomaxis: (*boolean*) Optional, set bottom axis visible or not. Default is ``True`` . :param leftaxis: (*boolean*) Optional, set left axis visible or not. Default is ``True`` . :param topaxis: (*boolean*) Optional, set top axis visible or not. Default is ``True`` . :param rightaxis: (*boolean*) Optional, set right axis visible or not. Default is ``True`` . :param xaxistype: (*string*) Optional, set x axis type as 'normal', 'lon', 'lat' or 'time'. :param xreverse: (*boolean*) Optional, set x axis reverse or not. Default is ``False`` . :param yreverse: (*boolean*) Optional, set yaxis reverse or not. Default is ``False`` . :returns: The axes. """ tickfontname = kwargs.pop('tickfontname', 'Arial') tickfontsize = kwargs.pop('tickfontsize', 14) tickbold = kwargs.pop('tickbold', False) if tickbold: font = Font(tickfontname, Font.BOLD, tickfontsize) else: font = Font(tickfontname, Font.PLAIN, tickfontsize) ax.axes.setAxisTickFont(font) return ax
def set_title(self, label, fontname=None, fontsize=14, bold=True, color='black'): """ Add a centered title to the figure. :param label: (*string*) Title label string. :param fontname: (*string*) Font name. Default is ``Arial`` . :param fontsize: (*int*) Font size. Default is ``14`` . :param bold: (*boolean*) Is bold font or not. Default is ``True`` . :param color: (*color*) Title string color. Default is ``black`` . """ exfont = False if fontname is None: fontname = 'Arial' else: exfont = True if bold: font = Font(fontname, Font.BOLD, fontsize) else: font = Font(fontname, Font.PLAIN, fontsize) c = plotutil.getcolor(color) ctitle = ChartText(label, font) ctitle.setUseExternalFont(exfont) ctitle.setColor(c) self.getChart().setTitle(ctitle) return ctitle
def set_zticklabels(self, labels, **kwargs): ''' Set z axis tick labels. ''' axis = self.axes.getZAxis() if not labels is None: if isinstance(labels, (NDArray, DimArray)): labels = labels.aslist() if isinstance(labels[0], (int, long, float)): axis.setTickLabels_Number(labels) else: axis.setTickLabelText(labels) fontname = kwargs.pop('fontname', axis.getTickLabelFont().getName()) fontsize = kwargs.pop('fontsize', axis.getTickLabelFont().getSize()) bold = kwargs.pop('bold', axis.getTickLabelFont().isBold()) if bold: font = Font(fontname, Font.BOLD, fontsize) else: font = Font(fontname, Font.PLAIN, fontsize) color = kwargs.pop('color', axis.getTickLabelColor()) c = plotutil.getcolor(color) angle = kwargs.pop('rotation', 0) if angle == 'vertical': angle = 90 axis.setTickLabelFont(font) axis.setTickLabelColor(c) axis.setTickLabelAngle(angle)
def initGui(self): self.sigv4ConfigurationTab = swing.JPanel() layout = swing.GroupLayout(self.sigv4ConfigurationTab) self.sigv4ConfigurationTab.setLayout(layout) self.addDomainInfo = swing.JLabel("Domain to test:") self.addDomainInfo.setFont(Font("Tahoma", 1, 12)) self.configurationLoadedInfo = swing.JLabel("") self.configurationLoadedInfo.setFont(Font("Tahoma", 1, 12)) self.isJsonCheck = swing.JCheckBox("JSON") self.isJsonCheck.setFont(Font("Tahoma", 1, 12)) self.parseCredsBtn = swing.JButton('Load configuration', actionPerformed=self.parseCreds) self.credsPanel = swing.JScrollPane() self.credsText = swing.JTextArea("Paste Creds Here.") self.credsText.setLineWrap(True) self.credsPanel.setViewportView(self.credsText) self.scopeUrlField = swing.JTextField("api.example.io") layout.setHorizontalGroup( layout.createParallelGroup(swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(15) .addGroup(layout.createParallelGroup(swing.GroupLayout.Alignment.LEADING) .addComponent(self.isJsonCheck) .addComponent(self.credsPanel, swing.GroupLayout.PREFERRED_SIZE, 525, swing.GroupLayout.PREFERRED_SIZE) .addComponent(self.addDomainInfo) .addComponent(self.scopeUrlField, swing.GroupLayout.PREFERRED_SIZE, 350, swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(swing.GroupLayout.Alignment.TRAILING) .addComponent(self.parseCredsBtn)) .addComponent(self.configurationLoadedInfo) .addPreferredGap(swing.LayoutStyle.ComponentPlacement.UNRELATED)) .addComponent(self.addDomainInfo)) .addContainerGap(26, lang.Short.MAX_VALUE))) layout.setVerticalGroup( layout.createParallelGroup(swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10) .addComponent(self.isJsonCheck) .addGap(10) .addComponent(self.credsPanel, swing.GroupLayout.PREFERRED_SIZE, 125, swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10) .addComponent(self.addDomainInfo) .addGap(10) .addComponent(self.scopeUrlField, swing.GroupLayout.PREFERRED_SIZE, swing.GroupLayout.DEFAULT_SIZE, swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10) .addComponent(self.parseCredsBtn) .addGap(10) .addComponent(self.configurationLoadedInfo) .addPreferredGap(swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(swing.LayoutStyle.ComponentPlacement.RELATED) .addContainerGap(swing.GroupLayout.DEFAULT_SIZE, lang.Short.MAX_VALUE))))))) return
def initUI(self): self.tab = swing.JPanel() # UI for Output self.outputLabel = swing.JLabel("pMDetector Log:") self.outputLabel.setFont(Font("Tahoma", Font.BOLD, 14)) self.outputLabel.setForeground(Color(255, 102, 52)) self.logPane = swing.JScrollPane() self.outputTxtArea = swing.JTextArea() self.outputTxtArea.setFont(Font("Consolas", Font.PLAIN, 12)) self.outputTxtArea.setLineWrap(True) self.logPane.setViewportView(self.outputTxtArea) self.clearBtn = swing.JButton("Clear Log", actionPerformed=self.clear) self.exportBtn = swing.JButton("Export Log", actionPerformed=self.export) self.parentFrm = swing.JFileChooser() # Layout layout = swing.GroupLayout(self.tab) layout.setAutoCreateGaps(True) layout.setAutoCreateContainerGaps(True) self.tab.setLayout(layout) layout.setHorizontalGroup(layout.createParallelGroup().addGroup( layout.createSequentialGroup().addGroup( layout.createParallelGroup().addComponent( self.outputLabel).addComponent(self.logPane).addComponent( self.clearBtn).addComponent(self.exportBtn)))) layout.setVerticalGroup(layout.createParallelGroup().addGroup( layout.createParallelGroup().addGroup( layout.createSequentialGroup().addComponent( self.outputLabel).addComponent(self.logPane).addComponent( self.clearBtn).addComponent(self.exportBtn))))
def __init__(self, program): self.setLayout(BorderLayout()) title = JLabel(program.title) title.setFont(Font("Arial", Font.BOLD, 28)) title.setHorizontalAlignment(JLabel.CENTER) title.setVerticalAlignment(JLabel.CENTER) title.setBorder(createEmptyBorder(15, 5, 15, 5)) if not program.public: lbl = JLabel("Private") lbl.setFont(Font("Arial", Font.BOLD, 20)) lbl.setForeground(Color(0xFF2424)) lbl.setBorder(createEmptyBorder(15, 15, 15, 15)) leftbox = lbl else: leftbox = Box.createHorizontalGlue() btnbox = TitleBtnBox(program) btnbox.setBorder(createEmptyBorder(5, 5, 5, 5)) self.add(leftbox, BorderLayout.LINE_START) self.add(title, BorderLayout.CENTER) self.add(btnbox, BorderLayout.LINE_END) same_size(leftbox, btnbox) self.setMaximumSize(Dimension(99999, self.getPreferredSize().height))
def run(self): frame = JFrame('FrameMethods', size=(1000, 500), locationRelativeTo=None, layout=GridLayout(0, 2), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) self.one = self.parse(self.textFile('JFrame Methods.txt')) self.left = JTextArea(self.one, 20, 40, editable=0, font=Font('Courier', Font.PLAIN, 12)) frame.add(JScrollPane(self.left)) self.two = self.parse(self.textFile('JInternalFrame Methods.txt')) self.right = JTextArea(self.two, 20, 40, editable=0, font=Font('Courier', Font.PLAIN, 12)) frame.add(JScrollPane(self.right)) frame.setJMenuBar(self.makeMenu()) frame.setVisible(1)
def drawBox(b): rr = rectForBox(b) outputTo, qq, qq2 = mergeGroup.create( b.get("box").get("id"), rr, VisualElement, PlainDraggableComponent, SplineComputingOverride) outputTo.name = b.get("box").get("id") if (mergeGroup.getLastWasNew()): outputTo.python_source_v = "" if (outputTo.where.python_autoExec_v != outputTo): outputTo.python_autoExec_v = "" outputTo.decoration_frame = ArrayList() if (b.get("box").has("varname")): tt = b.get("box").get("varname") text = PLine().moveTo(0, -9) text.containsText = 1 text.text_v = tt text.font_v = Font("Gill Sans", 2, 10) text.derived = 1 text.alignment_v = -1 text(offsetFromSource=Vector2(1, 0)) text(color=Vector4(0.25, 0, 0, 1)) outputTo.decoration_frame.add(text) hasVarName = 1 outputTo.maxBox = tt outputTo.needsMax = True else: hasVarName = 0 outputTo.setFrame(rr) pp = PLine().roundRect(Rect(0, 0, rr.w, rr.h), radius=15)(offsetFromSource=Vector2(0, 0)) outputTo.noFrame = 1 pp(derived=1, filled=1, color=Vector4([0, 0.25][hasVarName], 0, 0, 0.2)) outputTo.decoration_frame.add(pp) pp = PLine().roundRect(Rect(0, 0, rr.w, rr.h), radius=15)(offsetFromSource=Vector2(0, 0)) outputTo.noFrame = 1 pp(derived=1, filled=0, color=Vector4(0, 0, 0, 0.5), onSourceSelectedOnly=1) outputTo.decoration_frame.add(pp) if (b.get("box").has("text")): tt = b.get("box").get("text") text = PLine().moveTo(5, -3) text.containsText = 1 text.text_v = tt text.font_v = Font("Gill Sans", 0, 12) text.derived = 1 text(offsetFromSource=Vector2(0, 0.5)) outputTo.decoration_frame.add(text)
def getfont_1(**kwargs): fontname = kwargs.pop('fontname', 'Arial') fontsize = kwargs.pop('fontsize', 14) bold = kwargs.pop('bold', False) if bold: font = Font(fontname, Font.BOLD, fontsize) else: font = Font(fontname, Font.PLAIN, fontsize) return font
def __init__(self, *args, **kwargs): """ Axes 3d with openGL support. :param position: (*list of float*) Axes position specified by *position=* [left, bottom, width height] in normalized (0, 1) units. Default is [0.13, 0.11, 0.775, 0.815]. :param rotation: (*float*) Axes rotation angle around Z axis. :param elevation: (*float*) Axes elevation angle with Z axis. :param antialias: (*bool*) Antialias or not. Default is `None`. """ axes = kwargs.pop('axes', None) self._set_plot(axes) figure = kwargs.pop('figure', None) self.figure = figure if len(args) > 0: position = args[0] else: position = kwargs.pop('position', None) outerposition = kwargs.pop('outerposition', None) if position is None: position = [0.13, 0.11, 0.71, 0.815] self.active_outerposition(True) else: self.active_outerposition(False) self.set_position(position) if not outerposition is None: self.set_outerposition(outerposition) self.active_outerposition(True) bgcolor = kwargs.pop('bgcolor', None) if not bgcolor is None: bgcolor = plotutil.getcolor(bgcolor) self.axes.setBackground(bgcolor) units = kwargs.pop('units', None) if not units is None: self.axes.setUnits(units) tickfontname = kwargs.pop('tickfontname', 'Arial') tickfontsize = kwargs.pop('tickfontsize', 14) tickbold = kwargs.pop('tickbold', False) if tickbold: font = Font(tickfontname, Font.BOLD, tickfontsize) else: font = Font(tickfontname, Font.PLAIN, tickfontsize) self.axes.setAxisTickFont(font) rotation = kwargs.pop('rotation', None) if not rotation is None: self.axes.setAngleY(rotation) elevation = kwargs.pop('elevation', None) if not elevation is None: self.axes.setAngleX(elevation) antialias = kwargs.pop('antialias', None) if not antialias is None: self.axes.setAntialias(antialias)
def zaxis(self, **kwargs): """ Set z axis of the axes. :param color: (*Color*) Color of the z axis. Default is 'black'. :param shift: (*int) z axis shif along horizontal direction. Units is pixel. Default is 0. """ visible = kwargs.pop('visible', None) shift = kwargs.pop('shift', None) color = kwargs.pop('color', None) if not color is None: color = plotutil.getcolor(color) linewidth = kwargs.pop('linewidth', None) linestyle = kwargs.pop('linestyle', None) tickline = kwargs.pop('tickline', None) tickline = kwargs.pop('tickvisible', tickline) tickwidth = kwargs.pop('tickwidth', None) ticklabel = kwargs.pop('ticklabel', None) minortick = kwargs.pop('minortick', False) minorticknum = kwargs.pop('minorticknum', 5) tickin = kwargs.pop('tickin', True) axistype = kwargs.pop('axistype', None) tickfontname = kwargs.pop('tickfontname', 'Arial') tickfontsize = kwargs.pop('tickfontsize', 14) tickbold = kwargs.pop('tickbold', False) if tickbold: font = Font(tickfontname, Font.BOLD, tickfontsize) else: font = Font(tickfontname, Font.PLAIN, tickfontsize) axislist = [] axislist.append(self.axes.getZAxis()) for axis in axislist: if not visible is None: axis.setVisible(visible) if not shift is None: axis.setShift(shift) if not color is None: axis.setColor_All(color) if not linewidth is None: axis.setLineWidth(linewidth) if not linestyle is None: axis.setLineStyle(linestyle) if not tickline is None: axis.setDrawTickLine(tickline) if not tickwidth is None: stroke = BasicStroke(tickwidth) axis.setTickStroke(stroke) if not ticklabel is None: axis.setDrawTickLabel(ticklabel) axis.setMinorTickVisible(minortick) axis.setMinorTickNum(minorticknum) axis.setInsideTick(tickin) axis.setTickLabelFont(font)
def set_font(): """ Loads font from resources' ttf file. DejaVuSans doesn't work in Retina display screens properly, so check OS, if OSX then use Monaco instead. """ if "mac" in System.getProperty("os.name").lower(): font = Font("Monaco", Font.PLAIN, 14) else: path_to_ttf = 'resources/fonts/dejavu/ttf/DejaVuSans.ttf' loader = ClassLoader.getSystemClassLoader() stream = loader.getResourceAsStream(path_to_ttf) font = Font.createFont(Font.TRUETYPE_FONT, stream) font = font.deriveFont(Font.PLAIN, 14) return font
def run(fontsize): # Get map of all open scripting interpreters instances = getField(AbstractInterpreter, "instances", None) # static if 0 == len(instances): print "No instances open!" return # Filter Jython_Interpreter instances jis = [ instance for instance in instances.values() if instance.getClass().getName() == "Jython.Jython_Interpreter" ] if 0 == len(jis): print "No Jython instances open!" return # The Jython Intepreter ji = jis[0] # Get text fields screen = getField(AbstractInterpreter, "screen", ji) # JTextArea prompt = getField(AbstractInterpreter, "prompt", ji) # JTextArea # Edit font size font = screen.getFont() font2 = Font(font.getName(), font.getStyle(), fontsize) print font print font2 screen.setFont(font2) prompt.setFont(font2)
def run(self): frame = JFrame('ComponentEventDemo', locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) cp = frame.getContentPane() cp.setLayout(BorderLayout()) self.display = JTextArea(editable=0, font=Font('Courier', Font.PLAIN, 12)) myListener = listener(self.display) frame.addComponentListener(myListener) scrollPane = JScrollPane(self.display, preferredSize=Dimension(350, 210)) cp.add(scrollPane, BorderLayout.CENTER) panel = JPanel(BorderLayout(), componentListener=myListener) self.button = JButton('Clear', actionPerformed=self.clear, componentListener=myListener) panel.add(self.button, BorderLayout.CENTER) visible = JCheckBox('Button visible', selected=1, itemStateChanged=self.showHide, componentListener=myListener) panel.add(visible, BorderLayout.PAGE_END) cp.add(panel, BorderLayout.PAGE_END) frame.pack() frame.setVisible(1)
def show(self, at=None, blending=1, decor=1, name=None, extents=None, scale = None): if (not at): at = self.defaultPosition r1 = extents or self.image().getExtents() line = PLine().moveTo(at[0]+r1.x, at[1]+r1.y) line.containsImages=1 self.blending = blending line.image_v=self line.imageDrawScale_v = scale or self.defaultScale getSelf().lines.add(line) if (decor): rOuter = PLine().rect(Rect(at[0]+r1.x, at[1]+r1.y, r1.w, r1.h)) rInner = PLine().rect(Rect(at[0],at[1],r1.w+2*r1.x,r1.h+2*r1.y)) rOuter.color=Vector4(0,0,0,0.5) rInner.color=Vector4(0,0,0,0.5) rOuter.derived=1 rInner.derived=1 rOuter.thickness=0.5 rInner.thickness=0.5 rOuter.strokeType = BasicStroke(0.5, 1, 1, 1, (10,10),0) getSelf().lines.add(rOuter) getSelf().lines.add(rInner) if (name): annotation = PLine().moveTo(at[0]+(r1.w+2*r1.x)/2,at[1]+r1.h+16) annotation.containsText=1 annotation.text_v = name annotation.font_v = Font("Gill Sans", 0, 14) annotation.derived=1 annotation.color_v=Vector4(0,0,0,0.15) getSelf().lines.add(annotation)
def __init__(self, burp, namespace=None): self.burp = burp self.log = burp.log self._locals = dict(Burp=burp) self._buffer = [] self.history = History(self) if namespace is not None: self._locals.update(namespace) self.interp = JythonInterpreter(self, self._locals) self.textpane = JTextPane(keyTyped=self.keyTyped, keyPressed=self.keyPressed) self.textpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.burp.customizeUiComponent(self.textpane) self.initKeyMap() self.document.remove(0, self.document.getLength()) self.write('Burp Extender Jython Shell', prefix='') self.write(self.PS1) self.textpane.requestFocus() burp.log.info('Interactive interpreter ready...')
def __init__(self): dataDir = Settings.dataDir + 'WorkingWith2DBarcodes/Utility2DBarcodeFeatures/HideCodeText/' # Instantiate barcode object builder = BarCodeBuilder() symbology = Symbology builder.setSymbologyType(symbology.DataMatrix) builder.setCodeText( "The quick brown fox jumps over the lazy dog\n The quick brown fox jumps over the lazy dog\n" ) codeLocation = CodeLocation builder.setCodeLocation(codeLocation.None) font = Font builder.setCodeTextFont(Font("Serif", font.BOLD + font.ITALIC, 20)) # Save the image builder.save(dataDir + "HideCodeText.jpg") # Display Status print "Hide Code Text Successfully."
def createLabelColorBar(): imp7 = ImagePlus("labelColorBar", ShortProcessor(180, 20)) ip7 = imp7.getProcessor() pix = ip7.getPixels() n_pixels = len(pix) # catch width w = imp7.getWidth() # create a ramp gradient from left to right for i in range(len(pix)): pix[i] = int((i % w) / 18) + 1 # adjust min and max ip7.setMinAndMax(0, 255) font = Font("SansSerif", Font.PLAIN, 12) overlay = Overlay() for i in range(len(pix)): roi = TextRoi(i * 18 + 2, 2, str(i + 1), font) roi.setStrokeColor(Color.black) overlay.add(roi) imp7.setOverlay(overlay) imp7.show() IJ.run("glasbey_on_dark") imp7 = imp7.flatten() return imp7
def set_font(font_size): ''' Loads font from resources' ttf file. DejaVuSans doesn't work in Retina display screens properly, so check OS, if OSX then use Monaco instead. ''' # Take into account user preferred font size if "mac" in System.getProperty("os.name").lower(): font = Font("Monaco", Font.PLAIN, font_size) else: path_to_ttf = 'resources/fonts/dejavu/ttf/DejaVuSans.ttf' loader = ClassLoader.getSystemClassLoader() stream = loader.getResourceAsStream(path_to_ttf) font = Font.createFont(Font.TRUETYPE_FONT, stream) font = font.deriveFont(Font.PLAIN, font_size) return font
def __init__(self, center, text, size = 50, borderSize = 1, borderColor = Color.black, textColor = Color.black, bgColor = Color.white, font = Font("Courier", Font.PLAIN, 14)): self.center = center self.text = text self.size = size self.borderSize = borderSize self.borderColor = _toColor(borderColor) if type(self.borderColor) in [str, unicode]: self.borderColor = GPanel.toColor(self.borderColor) self.textColor = _toColor(textColor) if type(self.textColor) in [str, unicode]: self.textColor = GPanel.toColor(self.textColor) self.bgColor = _toColor(bgColor) if type(self.bgColor) in [str, unicode]: self.bgColor = GPanel.toColor(self.bgColor) self.font = font p.drawNode(self.center[0], self.center[1], self.text, self.size, self.borderSize, self.borderColor, self.textColor, self.bgColor, self.font)
def __init__(self, extender, namespace=None): self.extender = extender self.callbacks = extender.callbacks self.helpers = extender.helpers self._locals = dict(Burp=extender, items=[]) self._buffer = [] self.history = History(self) if namespace is not None: self._locals.update(namespace) self.interp = JythonInterpreter(self, self._locals) self.textpane = JTextPane(keyTyped=self.keyTyped, keyPressed=self.keyPressed) self.textpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.callbacks.customizeUiComponent(self.textpane) self.initKeyMap() self.document.remove(0, self.document.getLength()) self.write('Burp Extender Jython Shell', prefix='') self.write(self.PS1) self.textpane.requestFocus() self.callbacks.getStdout().write('Interactive interpreter ready...\n')
def run(self): frame = JFrame('MethodTable2', defaultCloseOperation=JFrame.EXIT_ON_CLOSE) #----------------------------------------------------------------------- # Get the text to be processed #----------------------------------------------------------------------- helpText = Help.help().expandtabs() #----------------------------------------------------------------------- # Verify our help text parsing routine #----------------------------------------------------------------------- headings = ['Method', 'Description / Abstract'] #----------------------------------------------------------------------- # Let's try to highlight every instance of "help" in the table #----------------------------------------------------------------------- data = self.parseMethodHelp(helpText) for r in range(len(data)): for c in range(len(data[r])): data[r][c] = self.hiliteText(data[r][c], 'help') #----------------------------------------------------------------------- # Create the JTable using the massaged data and column headings #----------------------------------------------------------------------- table = JTable(data, headings, font=Font('Courier', Font.PLAIN, 12)) frame.add(JScrollPane(table), 'Center') frame.pack() self.center(frame) frame.setVisible(1)
def run( self ) : frame = JFrame( 'WSAShelp_01', locationRelativeTo = None, defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) # text = Help.help() # tabs = text.count( '\t' ) # text = Help.help().expandtabs() # rows = text.count( '\n' ) + 1 # cols = max( [ len( x ) for x in text.splitlines() ] ) # cols = max( [ len( x.expandtabs() ) for x in text.splitlines() ] ) # print '\nrows: %d cols: %d tabs: %d' % ( rows, cols, tabs ) frame.add( JScrollPane( JTextArea( # text, Help.help().expandtabs(), 20, 80, font = Font( 'Courier' , Font.PLAIN, 12 ) ) ) ) frame.pack() size = frame.getSize() # print 'frame.getSize():', size loc = frame.getLocation() # print 'frame.getLocation():', loc loc.x -= ( size.width >> 1 ) loc.y -= ( size.height >> 1 ) frame.setLocation( loc ) frame.setVisible( 1 )
def create_ui(self): cpanel = CreatePanle(self._burpColor) self.content_ui = swing.JPanel() content_panel = swing.JPanel() content_panel.setLayout(BorderLayout()) text = swing.JLabel(self.option['text']) if self.option['type'] == 'file_chooser': #fileSelecter button = cpanel.create_button(self.option['funcopt']['FNfilter'], self.option, content_panel) button.setPreferredSize(Dimension(40, 40)) elif self.option['type'] == 'param_list': ui = cpanel.create_table_panel(self.option) content_panel.add(ui) elif self.option['type'] == 'file_loader': button = cpanel.create_button(self.option['funcopt']['FNfilter'], self.option, content_panel) button.setPreferredSize(Dimension(40, 40)) text.setFont(Font("Arial", Font.PLAIN, 12)) content_panel.add(text, BorderLayout.PAGE_START) self.content_ui.setLayout(BorderLayout()) self.content_ui.add(content_panel) if self.option['type'] == 'file_chooser' or self.option[ 'type'] == 'file_loader': self.content_ui.add(button, BorderLayout.SOUTH)
def __init__(self, view, name): core.DataViewComponent.__init__(self) self.view = view self.name = name self.resize_border = 0 self.min_width = 5 self.min_height = 5 self.border_size = 5 self.arc_size = 20 self.label_font = Font.decode('Arial-20') self.type = None self.descent = None if(self.view.watcher.contains(name)): self.popup.add(JPopupMenu.Separator()) popup_menu = self.popup for (type, klass, args) in self.view.watcher.list(name): if(klass is JMenu): popup_menu = args self.popup.add(popup_menu) elif(klass is None): popup_menu = self.popup else: if '|' in type: text = type.split('|', 1)[0] else: text = type popup_menu.add( JMenuItem(text, actionPerformed=lambda event, self=self, klass=klass, args=args, type=type: self.add_component(type, klass, args)))
def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.helpers self.scriptpane = JTextPane() self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11)) self.scrollpane = JScrollPane() self.scrollpane.setViewportView(self.scriptpane) self._code = compile('', '<string>', 'exec') self._script = '' script = callbacks.loadExtensionSetting('script') if script: script = base64.b64decode(script) self.scriptpane.document.insertString( self.scriptpane.document.length, script, SimpleAttributeSet()) self._script = script try: self._code = compile(script, '<string>', 'exec') except Exception as e: traceback.print_exc(file=self.callbacks.getStderr()) callbacks.registerExtensionStateListener(self) callbacks.registerHttpListener(self) callbacks.customizeUiComponent(self.getUiComponent()) callbacks.addSuiteTab(self) self.scriptpane.requestFocus()
def top_panel(self): title = swing.JLabel(self._info['title'][0],swing.JLabel.LEFT) title.setFont(Font("Arial", Font.BOLD, 24)) title.setForeground(self._burpColor) self.compartment = swing.JPanel() self.compartment.add(title) self.compartment.setLayout(FlowLayout(FlowLayout.LEFT)) self.compartment.setMaximumSize(Dimension(Short.MAX_VALUE, 40))
def __init__(self, name, size): """ Return Font subclassed of java.awt.Font. Arguments include name and size of font. Currently font name limited to 'Arial'. """ self.fontname = 'Arial' self.fontsize = size try: self.fontstyle = self._style except AttributeError: self.fontstyle = JFont.PLAIN JFont.__init__(self,self.fontname,self.fontstyle,self.fontsize) self.font = self _g2d.setFont(self.font) self.fontMetrics = _g2d.getFontMetrics() self.underline = False self._nonimplemented_methods()
def __init__(self, name, size): """ Return Font subclassed of java.awt.Font. Arguments include name of a system font and size of font. The name argument can be a string of comma-delimited names to specify fallbacks and use a default font if none found, or specify a font file (eg. 'resource/font.ttf') with a exception if file not found. """ if not Font._font: Font._font = get_fonts() Font._font_default = get_default_font() self.fontname, isFile = self._getFontName(name) self.fontsize = size if not hasattr(self, 'fontstyle'): self.fontstyle = JFont.PLAIN if not isFile: JFont.__init__(self, self.fontname, self.fontstyle, self.fontsize) else: font = self._getFont(self.fontname, self.fontstyle, self.fontsize) JFont.__init__(self, font) self.font = self _g2d.setFont(self.font) self.fontMetrics = _g2d.getFontMetrics() self.underline = False self._nonimplemented_methods()
def create_font(font_name, size, is_bold=False, is_italic=False): assert font_name in _supported_fonts_path_mapping assert isinstance(size, float) assert isinstance(is_bold, bool) assert isinstance(is_italic, bool) font_base_path = os.path.join(common.get_project_base_path(), 'resources', 'fonts') fonts = _supported_fonts_path_mapping[font_name] if is_bold and is_italic: font_path = os.path.join(font_base_path, fonts['bold-italic']) elif is_bold: font_path = os.path.join(font_base_path, fonts['bold']) elif is_italic: font_path = os.path.join(font_base_path, fonts['italic']) else: font_path = os.path.join(font_base_path, fonts['regular']) assert os.path.isfile(font_path) font = Font.createFont(Font.TRUETYPE_FONT, File(font_path)) return font.deriveFont(size)
def __init__(self, clientstate=None) : self.client_state = clientstate self.font = Font.decode(None) self.context = BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).getGraphics().getFontRenderContext()
# -*- coding: utf-8 -*- from java.awt import Font from game.rpg.process.event import * from game.rpg.util import * if __name__ == '__main__': # font font_file = Loader.getResourceAsFile("font/mother2.TTF") font = Font.createFont(Font.TRUETYPE_FONT, font_file).deriveFont(float(13.0)) EventCommand.setMessageFont(font) # text EventCommand.showText(u"いまは 8じ じゃないかって?\fああ えきのとけいは\nこわれてるんだよ\fけっして てぬきをした\nわけではないから\nかんちがい しないように")