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
     
    9393 
    9494                Graphics2D graphics = (Graphics2D) g2d.create(); 
    9595                graphics.translate(x, y); 
    96  
     96                awtLayout.draw(graphics, 0f, 0f); 
    9797                boolean caretHandled = false; 
    9898                for (Iterator<HotHighlight> iter = highlights.getIterator(); iter.hasNext();) { 
    9999                        HotHighlight highlight = iter.next(); 
    100100                        drawHighlight(graphics, highlight, !caretHandled, isLast); 
    101101                        caretHandled = true; 
    102102                } 
    103                 awtLayout.draw(graphics, 0f, 0f); 
    104  
     103                 
    105104                graphics.dispose(); 
    106105        } 
    107106 
     
    126125                HotPos end = intersection.getEnd(); 
    127126                HotIndexInterval interval = TextUtils.posToIndexInterval(this.text,  
    128127                                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                } 
    129140                if (withCaret) { 
    130141                        HotPos caretPos = end; 
    131142                        HotPos textEnd = this.text.getEnd(); 
     
    142153                                graphics.draw(carets[0]); 
    143154                        } 
    144155                } 
    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                 } 
    156156        } 
    157157 
    158158        private TextLayout awtLayoutCache = null; 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/helpers/HotTextElementHelper.java

     
    8888                        assert caretPos != null; 
    8989                         
    9090                        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)); 
    9292                        HotStyleDef style = HotStyleDef.getEmpty().derive(styleValues); 
    9393                        HotHighlight h = new HotHighlight(new HotInterval(markPos, caretPos),  
    9494                                        style); 
  • modules/org.sophie2.base.model.text/src/main/java/org/sophie2/base/model/text/mvc/swing/SimpleSwingTextView.java

     
    111111                        g2d.draw(textFlow().get().getAreas().get(0).toShape()); 
    112112                         
    113113                        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)); 
    115115                        HotStyleDef style = HotStyleDef.getEmpty().derive(styleValues); 
    116116                         
    117117                        HotPos caretPos = textFlow().get().caretPos().get(); 
  • modules/org.sophie2.main.func.text/src/main/java/org/sophie2/main/func/text/view/HotTextLogic.java

     
    170170                        Matcher matcher = pattern.matcher(text); 
    171171                        if (matcher.find()) { 
    172172                                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)); 
    174174                                HotStyleDef style = HotStyleDef.getEmpty().derive(styleValues); 
    175175                                HotInterval interval = new HotInterval(sText.advance(currentPos, scale 
    176176                                                * 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

     
    4646                /** 
    4747                 * Handles text color changing. 
    4848                 */ 
    49                 ON_COLOR_SUBMI { 
     49                ON_COLOR_SUBMIT { 
    5050 
    5151                        public void defineFilter(EventFilterBuilder filter) { 
    5252                                filter.setSourceClass(TextColorField.class);