Ticket #2111: highlight.patch
File highlight.patch, 5.6 KB (added by diana, 15 years ago) |
---|
-
modules/org.sophie2.base.model.text/src/main/java/org/sophie2/base/model/text/smart/layout/HotSegmentLayout.java
### Eclipse Workspace Patch 1.0 #P sophie
93 93 94 94 Graphics2D graphics = (Graphics2D) g2d.create(); 95 95 graphics.translate(x, y); 96 96 awtLayout.draw(graphics, 0f, 0f); 97 97 boolean caretHandled = false; 98 98 for (Iterator<HotHighlight> iter = highlights.getIterator(); iter.hasNext();) { 99 99 HotHighlight highlight = iter.next(); 100 100 drawHighlight(graphics, highlight, !caretHandled, isLast); 101 101 caretHandled = true; 102 102 } 103 awtLayout.draw(graphics, 0f, 0f); 104 103 105 104 graphics.dispose(); 106 105 } 107 106 … … 126 125 HotPos end = intersection.getEnd(); 127 126 HotIndexInterval interval = TextUtils.posToIndexInterval(this.text, 128 127 begin, end); 128 129 130 if (interval.getBegin() != interval.getEnd()) { 131 // Retrieve highlight region for selection range. 132 Shape highlightShape = awtLayout.getLogicalHighlightShape( 133 interval.getBegin(), interval.getEnd()); 134 // Fill the highlight region with the highlight color. 135 ImmColor bgColor = (ImmColor)highlight.getStyle().getValue(CommonAttr.BACKGROUND_COLOR); 136 137 graphics.setColor(bgColor.toAwtColor()); 138 graphics.fill(highlightShape); 139 } 129 140 if (withCaret) { 130 141 HotPos caretPos = end; 131 142 HotPos textEnd = this.text.getEnd(); … … 142 153 graphics.draw(carets[0]); 143 154 } 144 155 } 145 146 if (interval.getBegin() != interval.getEnd()) {147 // Retrieve highlight region for selection range.148 Shape highlightShape = awtLayout.getLogicalHighlightShape(149 interval.getBegin(), interval.getEnd());150 // Fill the highlight region with the highlight color.151 ImmColor bgColor = (ImmColor)highlight.getStyle().getValue(CommonAttr.BACKGROUND_COLOR);152 153 graphics.setColor(bgColor.toAwtColor());154 graphics.fill(highlightShape);155 }156 156 } 157 157 158 158 private TextLayout awtLayoutCache = null; -
modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/helpers/HotTextElementHelper.java
88 88 assert caretPos != null; 89 89 90 90 Map<HotAttr<?>, Object> styleValues = new HashMap<HotAttr<?>, Object>(); 91 styleValues.put(CommonAttr.BACKGROUND_COLOR, ImmColor.BLUE);91 styleValues.put(CommonAttr.BACKGROUND_COLOR, new ImmColor(0f,0f,1f,0.2f)); 92 92 HotStyleDef style = HotStyleDef.getEmpty().derive(styleValues); 93 93 HotHighlight h = new HotHighlight(new HotInterval(markPos, caretPos), 94 94 style); -
modules/org.sophie2.base.model.text/src/main/java/org/sophie2/base/model/text/mvc/swing/SimpleSwingTextView.java
111 111 g2d.draw(textFlow().get().getAreas().get(0).toShape()); 112 112 113 113 Map<HotAttr<?>, Object> styleValues = new HashMap<HotAttr<?>, Object>(); 114 styleValues.put(CommonAttr.BACKGROUND_COLOR, ImmColor.BLUE);114 styleValues.put(CommonAttr.BACKGROUND_COLOR, new ImmColor(0f, 0f, 1f, 0.2f)); 115 115 HotStyleDef style = HotStyleDef.getEmpty().derive(styleValues); 116 116 117 117 HotPos caretPos = textFlow().get().caretPos().get(); -
modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/view/HotTextLogic.java
170 170 Matcher matcher = pattern.matcher(text); 171 171 if (matcher.find()) { 172 172 Map<HotAttr<?>, Object> styleValues = new HashMap<HotAttr<?>, Object>(); 173 styleValues.put(CommonAttr.BACKGROUND_COLOR, ImmColor.YELLOW);173 styleValues.put(CommonAttr.BACKGROUND_COLOR, new ImmColor(1.0f, 1.0f, 0f, 0.2f)); 174 174 HotStyleDef style = HotStyleDef.getEmpty().derive(styleValues); 175 175 HotInterval interval = new HotInterval(sText.advance(currentPos, scale 176 176 * matcher.start()), sText.advance(currentPos, scale * matcher.end())); -
modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/styling/TextColorField.java
46 46 /** 47 47 * Handles text color changing. 48 48 */ 49 ON_COLOR_SUBMI {49 ON_COLOR_SUBMIT { 50 50 51 51 public void defineFilter(EventFilterBuilder filter) { 52 52 filter.setSourceClass(TextColorField.class);