public final Color getHandleColor() { return StyleConstants.getBackground(defaultActiveHandleStyle); }
public void init(DrawContext ctx) { foreColor = StyleConstants.getForeground(style); backColor = StyleConstants.getBackground(style); }
public void init(DrawContext ctx) { foreColor = StyleConstants.getForeground(style); backColor = StyleConstants.getBackground(style); }
/** * Save color preferences. * * @param file the file * @throws IOException Signals that an I/O exception has occurred. */ public void saveColorPreferences(File file) throws IOException { Properties prefs1 = new Properties(); Iterator<String> it = this.styleMap.keySet().iterator(); String type; Style style; Color fg, bg; while (it.hasNext()) { type = it.next(); style = this.styleMap.get(type); fg = StyleConstants.getForeground(style); bg = StyleConstants.getBackground(style); prefs1.setProperty(type, Integer.toString(fg.getRGB()) + "+" + Integer.toString(bg.getRGB())); } FileOutputStream out = new FileOutputStream(file); prefs1.store(out, "Color preferences for annotation viewer."); }
cssMap.put("background-color", colorToHex(StyleConstants.getBackground(style)));
@Override public void actionPerformed(ActionEvent event) { Style style = AnnotationDisplayCustomizationFrame.this.styleMap .get(AnnotationDisplayCustomizationFrame.this.currentTypeName); if (style == null) { style = AnnotationDisplayCustomizationFrame.this.styleMap.get(CAS.TYPE_NAME_ANNOTATION); } // assert(style != null); AnnotationDisplayCustomizationFrame.this.fgColor = StyleConstants.getForeground(style); AnnotationDisplayCustomizationFrame.this.fgIcon .setColor(AnnotationDisplayCustomizationFrame.this.fgColor); AnnotationDisplayCustomizationFrame.this.bgColor = StyleConstants.getBackground(style); AnnotationDisplayCustomizationFrame.this.bgIcon .setColor(AnnotationDisplayCustomizationFrame.this.bgColor); setCurrentStyle(style); setTextPane(); enableButtons(false); AnnotationDisplayCustomizationFrame.this.repaint(); }
@Override public void actionPerformed(ActionEvent event) { Style style = AnnotationDisplayCustomizationFrame.this.styleMap .get(AnnotationDisplayCustomizationFrame.this.currentTypeName); if (style == null) { style = AnnotationDisplayCustomizationFrame.this.textPane.addStyle( AnnotationDisplayCustomizationFrame.this.currentTypeName, AnnotationDisplayCustomizationFrame.this.styleMap.get(CAS.TYPE_NAME_ANNOTATION)); } StyleConstants.setForeground(style, StyleConstants .getForeground(AnnotationDisplayCustomizationFrame.this.currentStyle)); StyleConstants.setBackground(style, StyleConstants .getBackground(AnnotationDisplayCustomizationFrame.this.currentStyle)); AnnotationDisplayCustomizationFrame.this.styleMap.put( AnnotationDisplayCustomizationFrame.this.currentTypeName, style); enableButtons(false); AnnotationDisplayCustomizationFrame.this.repaint(); }
final Element element = doc.getCharacterElement(i); final AttributeSet set = element.getAttributes(); final Color backgroundColor = StyleConstants.getBackground(set); switch (state) { case LookingForField:
/** * Sets the current style. * * @param style the new current style */ private void setCurrentStyle(Style style) { // Copy style. this.currentStyle = this.textPane.addStyle(currentStyleName, style); StyleConstants.setForeground(this.currentStyle, StyleConstants.getForeground(style)); StyleConstants.setBackground(this.currentStyle, StyleConstants.getBackground(style)); }
setCurrentStyle(style); this.fgColor = StyleConstants.getForeground(this.currentStyle); this.bgColor = StyleConstants.getBackground(this.currentStyle); this.fgIcon = new ColorIcon(this.fgColor); this.bgIcon = new ColorIcon(this.bgColor);
public void removeAllBreakpoints() { final StyledDocument doc = (StyledDocument)editPane.getDocument(); final SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setBackground(sas, new java.awt.Color(233, 228, 242)); // https://stackoverflow.com/questions/28927274/get-attributes-of-selected-text-in-jtextpane for(int i = 0; i < doc.getLength(); i++) { final AttributeSet set = doc.getCharacterElement(i).getAttributes(); final Color backgroundColor = StyleConstants.getBackground(set); if (backgroundColor.equals(Color.cyan)) { // The breakpoint color. Remove breakpoint annotation from this text doc.setCharacterAttributes(i, 1, sas, false); } } }
/** * Sets the customization panel. * * @param typeName the new customization panel */ private void setCustomizationPanel(String typeName) { this.currentTypeName = typeName; Style defaultAnnotStyle = this.styleMap.get(CAS.TYPE_NAME_ANNOTATION); Style style = this.styleMap.get(typeName); if (style == null) { style = defaultAnnotStyle; } // Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle( // StyleContext.DEFAULT_STYLE); setCurrentStyle(style); this.fgColor = StyleConstants.getForeground(this.currentStyle); this.bgColor = StyleConstants.getBackground(this.currentStyle); this.fgIcon.setColor(this.fgColor); this.bgIcon.setColor(this.bgColor); setTextPane(); enableButtons(false); this.repaint(); }
break; case 49: StyleConstants.setBackground(ANSI, StyleConstants.getBackground(defaultStyle)); break;
break; case 49: StyleConstants.setBackground(ANSI, StyleConstants.getBackground(defaultStyle)); break;
StyleConstants.getBackground(attrSet) );
StyleConstants.getBackground(attrSet) );
StyleConstants.setBackground((MutableAttributeSet)attr,StyleConstants.getBackground(s));
/** This method returns the background color to be displayed at display position displayPosition, where the latter is assumed to be the position of a MarkableHandle. It is used for removing the highlighting from MarkableHandles, and returns either selectionBackgroundColor if the current MarkableHandle is in a currently selected Markable, or white otherwise. This is selection-sensitive! MarkableLayers are not accessed, so no active/inactive distinction necessary. */ public final Color getPrevailingBackgroundColorForMarkableHandle(int displayPosition) { // Use normal background as default Color resultColor = Color.white; // This assumes that no attribute-dependent background colors under MarkableHandles exist for Markables!! // That is correct, since no markables exist at markable handle positions (they are always at the borders of fragments). try { if ((currentDiscourse.getMMAX2().getCurrentPrimaryMarkable().coversDisplayPosition(displayPosition)) || (currentDiscourse.getMMAX2().getCurrentSecondaryMarkable().coversDisplayPosition(displayPosition))) { // displayPosition is in a currently selected Markable, so selectionbackgroundColor is prevailing there resultColor = StyleConstants.getBackground(currentDiscourse.getMMAX2().getSelectedStyle()); } } catch (java.lang.NullPointerException ex) { // no currently selectecd markables } return resultColor; }
@Test public void testColorize() throws BadLocationException { String message = "a55(a)a"; Collection<MessageFragmentStyle> colorize = colorizer.colorize(message); assertEquals(2, colorize.size()); ArrayList<MessageFragmentStyle> list = new ArrayList<>(colorize); MessageFragmentStyle messageFragmentStyle = list.get(0); MessageFragmentStyle messageFragmentStyle1 = list.get(1); assertEquals(messageFragmentStyle.isReplace(), false); assertEquals(messageFragmentStyle.getOffset(), 0); assertEquals(messageFragmentStyle.getLength(), message.length()); Style style = messageFragmentStyle.getStyle(); assertEquals(StyleConstants.getBackground(style), new Color(0, 255, 255)); assertEquals(StyleConstants.getForeground(style), new Color(255, 255, 0)); assertEquals((Boolean) StyleConstants.isBold(style), Boolean.FALSE); assertEquals((Boolean) StyleConstants.isItalic(style), Boolean.TRUE); assertEquals(messageFragmentStyle1.isReplace(), false); assertEquals(messageFragmentStyle1.getOffset(), 1); assertEquals(messageFragmentStyle1.getLength(), 5); Style style1 = messageFragmentStyle1.getStyle(); assertEquals(StyleConstants.getBackground(style1), new Color(0, 0, 255)); assertEquals(StyleConstants.getForeground(style1), new Color(255, 0, 0)); assertEquals((Boolean) StyleConstants.isBold(style1), Boolean.TRUE); assertEquals((Boolean) StyleConstants.isItalic(style1), Boolean.FALSE); } }
StyleConstants.setBackground(resultSet, StyleConstants.getBackground(superiorSet)); StyleConstants.setBackground(resultSet, StyleConstants.getBackground(inferiorSet));