Java Code Examples for java.text.AttributedCharacterIterator#getAllAttributeKeys()
The following examples show how to use
java.text.AttributedCharacterIterator#getAllAttributeKeys() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FXGraphics2D.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<AttributedCharacterIterator.Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 2
Source File: FXGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<AttributedCharacterIterator.Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 3
Source File: FXGraphics2D.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<AttributedCharacterIterator.Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 4
Source File: SVGGraphics2D.java From jfreesvg with GNU General Public License v3.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 5
Source File: FXGraphics2D.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<AttributedCharacterIterator.Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 6
Source File: FXGraphics2D.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<AttributedCharacterIterator.Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 7
Source File: FXGraphics2D.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Draws a string of attributed characters at {@code (x, y)}. * * @param iterator an iterator over the characters ({@code null} not * permitted). * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(AttributedCharacterIterator iterator, float x, float y) { Set<AttributedCharacterIterator.Attribute> s = iterator.getAllAttributeKeys(); if (!s.isEmpty()) { TextLayout layout = new TextLayout(iterator, getFontRenderContext()); layout.draw(this, x, y); } else { StringBuilder strb = new StringBuilder(); iterator.first(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { strb.append(iterator.current()); iterator.next(); } drawString(strb.toString(), x, y); } }
Example 8
Source File: AttributedStringTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static final void checkIteratorAttributeKeys(AttributedCharacterIterator iterator, Attribute[] expectedKeys) throws Exception { Set iteratorKeys = iterator.getAllAttributeKeys(); if (iteratorKeys.size() != expectedKeys.length) { throwException(iterator, "number of keys returned by iterator doesn't match expectation"); } for (int i = 0; i < expectedKeys.length; i++) { if (!iteratorKeys.contains(expectedKeys[i])) { throwException(iterator, "expected key wasn't found in iterator's key set"); } } }
Example 9
Source File: AttributedStringTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static final void dumpIterator(AttributedCharacterIterator iterator) { Set attributeKeys = iterator.getAllAttributeKeys(); System.out.print("All attributes: "); Iterator keyIterator = attributeKeys.iterator(); while (keyIterator.hasNext()) { Attribute key = (Attribute) keyIterator.next(); System.out.print(key); } for(char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { if (iterator.getIndex() == iterator.getBeginIndex() || iterator.getIndex() == iterator.getRunStart()) { System.out.println(); Map attributes = iterator.getAttributes(); Set entries = attributes.entrySet(); Iterator attributeIterator = entries.iterator(); while (attributeIterator.hasNext()) { Map.Entry entry = (Map.Entry) attributeIterator.next(); System.out.print("<" + entry.getKey() + ": " + entry.getValue() + ">"); } } System.out.print(" "); System.out.print(c); } System.out.println(); System.out.println("done"); System.out.println(); }
Example 10
Source File: AttributedStringTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static final void dumpIterator(AttributedCharacterIterator iterator) { Set attributeKeys = iterator.getAllAttributeKeys(); System.out.print("All attributes: "); Iterator keyIterator = attributeKeys.iterator(); while (keyIterator.hasNext()) { Attribute key = (Attribute) keyIterator.next(); System.out.print(key); } for(char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { if (iterator.getIndex() == iterator.getBeginIndex() || iterator.getIndex() == iterator.getRunStart()) { System.out.println(); Map attributes = iterator.getAttributes(); Set entries = attributes.entrySet(); Iterator attributeIterator = entries.iterator(); while (attributeIterator.hasNext()) { Map.Entry entry = (Map.Entry) attributeIterator.next(); System.out.print("<" + entry.getKey() + ": " + entry.getValue() + ">"); } } System.out.print(" "); System.out.print(c); } System.out.println(); System.out.println("done"); System.out.println(); }
Example 11
Source File: AttributedStringTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static final void checkIteratorAttributeKeys(AttributedCharacterIterator iterator, Attribute[] expectedKeys) throws Exception { Set iteratorKeys = iterator.getAllAttributeKeys(); if (iteratorKeys.size() != expectedKeys.length) { throwException(iterator, "number of keys returned by iterator doesn't match expectation"); } for (int i = 0; i < expectedKeys.length; i++) { if (!iteratorKeys.contains(expectedKeys[i])) { throwException(iterator, "expected key wasn't found in iterator's key set"); } } }
Example 12
Source File: AttributedStringTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static final void dumpIterator(AttributedCharacterIterator iterator) { Set attributeKeys = iterator.getAllAttributeKeys(); System.out.print("All attributes: "); Iterator keyIterator = attributeKeys.iterator(); while (keyIterator.hasNext()) { Attribute key = (Attribute) keyIterator.next(); System.out.print(key); } for(char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { if (iterator.getIndex() == iterator.getBeginIndex() || iterator.getIndex() == iterator.getRunStart()) { System.out.println(); Map attributes = iterator.getAttributes(); Set entries = attributes.entrySet(); Iterator attributeIterator = entries.iterator(); while (attributeIterator.hasNext()) { Map.Entry entry = (Map.Entry) attributeIterator.next(); System.out.print("<" + entry.getKey() + ": " + entry.getValue() + ">"); } } System.out.print(" "); System.out.print(c); } System.out.println(); System.out.println("done"); System.out.println(); }
Example 13
Source File: AttributedStringTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static final void checkIteratorAttributeKeys(AttributedCharacterIterator iterator, Attribute[] expectedKeys) throws Exception { Set iteratorKeys = iterator.getAllAttributeKeys(); if (iteratorKeys.size() != expectedKeys.length) { throwException(iterator, "number of keys returned by iterator doesn't match expectation"); } for (int i = 0; i < expectedKeys.length; i++) { if (!iteratorKeys.contains(expectedKeys[i])) { throwException(iterator, "expected key wasn't found in iterator's key set"); } } }
Example 14
Source File: AttributedStringTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static final void dumpIterator(AttributedCharacterIterator iterator) { Set attributeKeys = iterator.getAllAttributeKeys(); System.out.print("All attributes: "); Iterator keyIterator = attributeKeys.iterator(); while (keyIterator.hasNext()) { Attribute key = (Attribute) keyIterator.next(); System.out.print(key); } for(char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { if (iterator.getIndex() == iterator.getBeginIndex() || iterator.getIndex() == iterator.getRunStart()) { System.out.println(); Map attributes = iterator.getAttributes(); Set entries = attributes.entrySet(); Iterator attributeIterator = entries.iterator(); while (attributeIterator.hasNext()) { Map.Entry entry = (Map.Entry) attributeIterator.next(); System.out.print("<" + entry.getKey() + ": " + entry.getValue() + ">"); } } System.out.print(" "); System.out.print(c); } System.out.println(); System.out.println("done"); System.out.println(); }
Example 15
Source File: AttributedStringTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static final void checkIteratorAttributeKeys(AttributedCharacterIterator iterator, Attribute[] expectedKeys) throws Exception { Set iteratorKeys = iterator.getAllAttributeKeys(); if (iteratorKeys.size() != expectedKeys.length) { throwException(iterator, "number of keys returned by iterator doesn't match expectation"); } for (int i = 0; i < expectedKeys.length; i++) { if (!iteratorKeys.contains(expectedKeys[i])) { throwException(iterator, "expected key wasn't found in iterator's key set"); } } }
Example 16
Source File: AttributedStringTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static final void dumpIterator(AttributedCharacterIterator iterator) { Set attributeKeys = iterator.getAllAttributeKeys(); System.out.print("All attributes: "); Iterator keyIterator = attributeKeys.iterator(); while (keyIterator.hasNext()) { Attribute key = (Attribute) keyIterator.next(); System.out.print(key); } for(char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { if (iterator.getIndex() == iterator.getBeginIndex() || iterator.getIndex() == iterator.getRunStart()) { System.out.println(); Map attributes = iterator.getAttributes(); Set entries = attributes.entrySet(); Iterator attributeIterator = entries.iterator(); while (attributeIterator.hasNext()) { Map.Entry entry = (Map.Entry) attributeIterator.next(); System.out.print("<" + entry.getKey() + ": " + entry.getValue() + ">"); } } System.out.print(" "); System.out.print(c); } System.out.println(); System.out.println("done"); System.out.println(); }
Example 17
Source File: AttributedStringTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static final void checkIteratorAttributeKeys(AttributedCharacterIterator iterator, Attribute[] expectedKeys) throws Exception { Set iteratorKeys = iterator.getAllAttributeKeys(); if (iteratorKeys.size() != expectedKeys.length) { throwException(iterator, "number of keys returned by iterator doesn't match expectation"); } for (int i = 0; i < expectedKeys.length; i++) { if (!iteratorKeys.contains(expectedKeys[i])) { throwException(iterator, "expected key wasn't found in iterator's key set"); } } }
Example 18
Source File: AttributedStringSerializationWrapper.java From pumpernickel with MIT License | 4 votes |
public AttributedStringSerializationWrapper(AttributedString as) { AttributedCharacterIterator iter = as.getIterator(); Set<Attribute> allAttributes = iter.getAllAttributeKeys(); StringBuilder sb = new StringBuilder(); while (true) { char ch = iter.current(); if (ch == CharacterIterator.DONE) break; sb.append(ch); iter.next(); } Map<Attribute, List<Run>> runMap = new HashMap<>(); for (Attribute attribute : allAttributes) { AttributedCharacterIterator iter2 = as .getIterator(new Attribute[] { attribute }); List<Run> runs = new ArrayList<>(); int index = 0; while (true) { if (iter2.current() == CharacterIterator.DONE) break; Run lastRun = runs.isEmpty() ? null : runs.get(runs.size() - 1); Object value = iter2.getAttribute(attribute); if (lastRun != null && Objects.equals(lastRun.value, value)) { lastRun.endIndex++; } else { Run newRun = new Run(value, index); runs.add(newRun); } index++; iter2.next(); } for (Run run : runs) { for (SerializationFilter filter : AWTSerializationUtils.FILTERS) { Object filteredValue = filter.filter(run.value); if (filteredValue != null) run.value = filteredValue; } } runMap.put(attribute, runs); } map.put(KEY_STRING, sb.toString()); map.put(KEY_RUN_MAP, runMap); }