From: <nic...@us...> - 2017-01-04 01:26:49
|
Revision: 24582 http://sourceforge.net/p/jedit/svn/24582 Author: nicarran Date: 2017-01-04 01:26:46 +0000 (Wed, 04 Jan 2017) Log Message: ----------- new feature: thinner lines can now be configured using a factor Modified Paths: -------------- plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java plugins/CandyFolds/trunk/candyfolds/config/ModeConfig.java plugins/CandyFolds/trunk/candyfolds/config/gui/ModeConfigPanel.java Modified: plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java =================================================================== --- plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java 2016-12-31 21:12:59 UTC (rev 24581) +++ plugins/CandyFolds/trunk/candyfolds/TextAreaExt.java 2017-01-04 01:26:46 UTC (rev 24582) @@ -108,7 +108,8 @@ if(modeConfig.getUseThinStripesPixelSize()) thinBarStroke=new BasicStroke( 1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); else{ - float thinBarStrokeWidth=barStroke.getLineWidth()/2.3f; + float factor=modeConfig.getDrawThinStripesFactor(); + float thinBarStrokeWidth=barStroke.getLineWidth()*factor; if(thinBarStrokeWidth<1) thinBarStrokeWidth=1; thinBarStroke=new BasicStroke( thinBarStrokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND); Modified: plugins/CandyFolds/trunk/candyfolds/config/ModeConfig.java =================================================================== --- plugins/CandyFolds/trunk/candyfolds/config/ModeConfig.java 2016-12-31 21:12:59 UTC (rev 24581) +++ plugins/CandyFolds/trunk/candyfolds/config/ModeConfig.java 2017-01-04 01:26:46 UTC (rev 24582) @@ -28,7 +28,9 @@ import javax.swing.text.Segment; public final class ModeConfig { + public static final int MAX_STRIP_CONFIGS=25; + public static final float DEFAULT_DRAW_THIN_STRIPES_FACTOR=0.6f; public final Config config; public final String name; private final List<StripConfig> stripConfigs=new ArrayList<StripConfig>(); @@ -38,6 +40,7 @@ public final Regex ignoreLineRegex=new Regex(); private boolean showStripOn0Indent; private boolean drawThinStripes; + private float drawThinStripesFactor=DEFAULT_DRAW_THIN_STRIPES_FACTOR; private boolean useThinStripesPixelSize=false; ModeConfig(Config config, String name) { @@ -59,19 +62,19 @@ return useIgnoreLineRegex; } - public void setUseIgnoreLineRegex(boolean useIgnoreLineRegex){ + public void setUseIgnoreLineRegex(boolean useIgnoreLineRegex) { this.useIgnoreLineRegex=useIgnoreLineRegex; } - public boolean getShowStripOn0Indent(){ + public boolean getShowStripOn0Indent() { return showStripOn0Indent; } - public void setShowStripOn0Indent(boolean showStripOn0Indent){ + public void setShowStripOn0Indent(boolean showStripOn0Indent) { this.showStripOn0Indent=showStripOn0Indent; } - public void setDrawThinStripes(boolean drawThinStripes){ + public void setDrawThinStripes(boolean drawThinStripes) { this.drawThinStripes=drawThinStripes; } @@ -79,7 +82,15 @@ return drawThinStripes; } - public void setUseThinStripesPixelSize(boolean useThinStripesPixelSize){ + public float getDrawThinStripesFactor() { + return drawThinStripesFactor; + } + + public void setDrawThinStripesFactor(float v) { + this.drawThinStripesFactor=v; + } + + public void setUseThinStripesPixelSize(boolean useThinStripesPixelSize) { this.useThinStripesPixelSize=useThinStripesPixelSize; } @@ -89,7 +100,7 @@ public StripConfig addStripConfig() { if((config.defaultModeConfig==this && !stripConfigs.isEmpty()) - || stripConfigs.size()==MAX_STRIP_CONFIGS) + || stripConfigs.size()==MAX_STRIP_CONFIGS) return null; StripConfig stripConfig=new StripConfig(); stripConfigs.add(stripConfig); @@ -132,14 +143,18 @@ StringBuilder sb=new StringBuilder(); ps.clear(); ps.setProperty(getPropertyName(sb, "enabled"), String.valueOf(enabled)); - if(useIgnoreLineRegex){ + if(useIgnoreLineRegex) { String ignoreLineRegexValue=ignoreLineRegex.getValue(); if(ignoreLineRegexValue!=null && ignoreLineRegexValue.length()>0) ps.setProperty(getPropertyName(sb, "ignoreLineRegex"), ignoreLineRegexValue); - }else + } else ps.remove(getPropertyName(sb, "ignoreLineRegex")); ps.setProperty(getPropertyName(sb, "showStripOn0Indent"), String.valueOf(showStripOn0Indent)); ps.setProperty(getPropertyName(sb, "drawThinStripes"), String.valueOf(drawThinStripes)); + if(drawThinStripesFactor!=DEFAULT_DRAW_THIN_STRIPES_FACTOR) + ps.setProperty(getPropertyName(sb, "drawThinStripesFactor"), String.valueOf(drawThinStripesFactor)); + else + ps.remove(getPropertyName(sb, "drawThinStripesFactor")); ps.setProperty(getPropertyName(sb, "useThinStripesPixelSize"), String.valueOf(useThinStripesPixelSize)); for(int i=0, size=stripConfigs.size(); i<size && i<MAX_STRIP_CONFIGS; i++) { stripConfigs.get(i).store(ps, this, sb, i); @@ -166,26 +181,34 @@ StringBuilder sb=new StringBuilder(); if(this!=config.defaultModeConfig) setEnabled(Boolean.valueOf( - ps.getProperty(getPropertyName(sb, "enabled")) - )); + ps.getProperty(getPropertyName(sb, "enabled")) + )); setShowStripOn0Indent(Boolean.valueOf( - ps.getProperty(getPropertyName(sb, "showStripOn0Indent")) - )); + ps.getProperty(getPropertyName(sb, "showStripOn0Indent")) + )); setDrawThinStripes(Boolean.valueOf( - ps.getProperty(getPropertyName(sb, "drawThinStripes")) - )); + ps.getProperty(getPropertyName(sb, "drawThinStripes")) + )); + String drawThinStripesFactorValue=ps.getProperty(getPropertyName(sb, "drawThinStripesFactor")); + if(drawThinStripesFactorValue!=null) { + try { + setDrawThinStripesFactor(Float.valueOf( + drawThinStripesFactorValue + )); + } catch(NumberFormatException ex) {} + } setUseThinStripesPixelSize(Boolean.valueOf( - ps.getProperty(getPropertyName(sb, "useThinStripesPixelSize")) - )); + ps.getProperty(getPropertyName(sb, "useThinStripesPixelSize")) + )); //v support deprecated feature 'bigLines' with its ignoreLineRegexValue equivalent: String ignoreLineRegexValue=null; if(Boolean.valueOf( - ps.getProperty(getPropertyName(sb, "bigLines")))) + ps.getProperty(getPropertyName(sb, "bigLines")))) ignoreLineRegexValue="\\s*\\S\\s*$"; //^ if(ignoreLineRegexValue==null) ignoreLineRegexValue=ps.getProperty(getPropertyName(sb, "ignoreLineRegex")); - if(ignoreLineRegexValue!=null){ + if(ignoreLineRegexValue!=null) { useIgnoreLineRegex=true; ignoreLineRegex.setValue(ignoreLineRegexValue); } Modified: plugins/CandyFolds/trunk/candyfolds/config/gui/ModeConfigPanel.java =================================================================== --- plugins/CandyFolds/trunk/candyfolds/config/gui/ModeConfigPanel.java 2016-12-31 21:12:59 UTC (rev 24581) +++ plugins/CandyFolds/trunk/candyfolds/config/gui/ModeConfigPanel.java 2017-01-04 01:26:46 UTC (rev 24582) @@ -36,8 +36,10 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; +import org.gjt.sp.util.Log; class ModeConfigPanel { + private static final Logger L=Logger.getLogger(ModeConfigPanel.class.getName()); //static { L.setLevel(Level.ALL); } @@ -47,7 +49,8 @@ final JCheckBox useIgnoreLineRegexCB=new JCheckBox("Ignore lines matching regex:"); final JTextField ignoreLineRegexTF=new JTextField(12); final JCheckBox showStripOn0IndentCB=new JCheckBox("Show indentation-guide on left edge"); - final JCheckBox drawThinStripesCB=new JCheckBox("Draw thin stripes"); + final JCheckBox drawThinStripesCB=new JCheckBox("Thinner stripes by factor:"); + final JTextField drawThinStripesFactorTF=new JTextField(4); final JCheckBox useThinStripesPixelSizeCB=new JCheckBox("Use always 1 pixel"); private final StripConfigsTable stripConfigsTable=new StripConfigsTable(); private final JPanel tablePanel=new JPanel(new BorderLayout()); @@ -64,71 +67,79 @@ Box box=new Box(BoxLayout.Y_AXIS); enabledCB.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent ev) { - if(modeConfig!=null) - modeConfig.setEnabled(enabledCB.isSelected()); - updateView(); - } - } - ); + @Override + public void actionPerformed(ActionEvent ev) { + if(modeConfig!=null) + modeConfig.setEnabled(enabledCB.isSelected()); + updateView(); + } + } + ); box.add(enabledCB); Box p=new Box(BoxLayout.X_AXIS); p.setAlignmentX(0); - useIgnoreLineRegexCB.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(ActionEvent ev){ - boolean useIgnoreLineRegex=useIgnoreLineRegexCB.isSelected(); - if(modeConfig!=null) - modeConfig.setUseIgnoreLineRegex(useIgnoreLineRegex); - updateView(); - if(useIgnoreLineRegex){ - if(ignoreLineRegexTF.getText().trim().length()==0){ - ignoreLineRegexTF.setText("\\s*\\S\\s*$"); - ignoreLineRegexTF.selectAll(); - } - ignoreLineRegexTF.requestFocus(); - } + useIgnoreLineRegexCB.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + boolean useIgnoreLineRegex=useIgnoreLineRegexCB.isSelected(); + if(modeConfig!=null) + modeConfig.setUseIgnoreLineRegex(useIgnoreLineRegex); + updateView(); + if(useIgnoreLineRegex) { + if(ignoreLineRegexTF.getText().trim().length()==0) { + ignoreLineRegexTF.setText("\\s*\\S\\s*$"); + ignoreLineRegexTF.selectAll(); } - }); + ignoreLineRegexTF.requestFocus(); + } + } + }); p.add(useIgnoreLineRegexCB); - ignoreLineRegexTF.addFocusListener(new FocusAdapter(){ - @Override - public void focusLost(FocusEvent ev){ - updateModeConfigIgnoreLineRegex(); - updateView(); - } - }); + ignoreLineRegexTF.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent ev) { + updateModeConfigIgnoreLineRegex(); + updateView(); + } + }); p.add(ignoreLineRegexTF); box.add(p); - showStripOn0IndentCB.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(ActionEvent ev){ - if(modeConfig!=null) - modeConfig.setShowStripOn0Indent(showStripOn0IndentCB.isSelected()); - updateView(); - } - }); + showStripOn0IndentCB.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + if(modeConfig!=null) + modeConfig.setShowStripOn0Indent(showStripOn0IndentCB.isSelected()); + updateView(); + } + }); box.add(showStripOn0IndentCB); p=new Box(BoxLayout.X_AXIS); p.setAlignmentX(0); - drawThinStripesCB.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(ActionEvent ev){ - if(modeConfig!=null) - modeConfig.setDrawThinStripes(drawThinStripesCB.isSelected()); - updateView(); - } - }); + drawThinStripesCB.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + if(modeConfig!=null) + modeConfig.setDrawThinStripes(drawThinStripesCB.isSelected()); + updateView(); + } + }); p.add(drawThinStripesCB); - useThinStripesPixelSizeCB.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(ActionEvent ev){ - if(modeConfig!=null) - modeConfig.setUseThinStripesPixelSize(useThinStripesPixelSizeCB.isSelected()); - updateView(); - } - }); + drawThinStripesFactorTF.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent ev) { + updateModeConfigDrawThinStripesFactor(); + updateView(); + } + }); + p.add(drawThinStripesFactorTF); + useThinStripesPixelSizeCB.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + if(modeConfig!=null) + modeConfig.setUseThinStripesPixelSize(useThinStripesPixelSizeCB.isSelected()); + updateView(); + } + }); p.add(useThinStripesPixelSizeCB); box.add(p); panel.add(box, BorderLayout.NORTH); @@ -142,11 +153,21 @@ updateView(); } - private void updateModeConfigIgnoreLineRegex(){ + private void updateModeConfigIgnoreLineRegex() { if(modeConfig!=null) modeConfig.ignoreLineRegex.setValue(ignoreLineRegexTF.getText()); } + private void updateModeConfigDrawThinStripesFactor() { + if(modeConfig!=null) { + String factorS=drawThinStripesFactorTF.getText(); + try { + float newFactor=Float.valueOf(factorS); + modeConfig.setDrawThinStripesFactor(newFactor); + } catch(NumberFormatException ex) { } + } + } + private void updateView() { if(modeConfig!=null) { enabledCB.setSelected(modeConfig.getEnabled()); @@ -156,8 +177,8 @@ ignoreLineRegexTF.setText(modeConfig.ignoreLineRegex.getValue()); showStripOn0IndentCB.setSelected(modeConfig.getShowStripOn0Indent()); drawThinStripesCB.setSelected(modeConfig.getDrawThinStripes()); + drawThinStripesFactorTF.setText(Float.toString(modeConfig.getDrawThinStripesFactor())); useThinStripesPixelSizeCB.setSelected(modeConfig.getUseThinStripesPixelSize()); - useThinStripesPixelSizeCB.setVisible(drawThinStripesCB.isSelected()); stripConfigsOpPanel.panel.setVisible( modeConfig!=modeConfig.config.defaultModeConfig); } @@ -165,7 +186,8 @@ ignoreLineRegexTF.setEnabled(enabledCB.isSelected() && useIgnoreLineRegexCB.isSelected()); showStripOn0IndentCB.setEnabled(enabledCB.isSelected()); drawThinStripesCB.setEnabled(enabledCB.isSelected()); - useThinStripesPixelSizeCB.setEnabled(enabledCB.isSelected()); + drawThinStripesFactorTF.setEnabled(enabledCB.isSelected() && drawThinStripesCB.isSelected() && !useThinStripesPixelSizeCB.isSelected()); + useThinStripesPixelSizeCB.setEnabled(enabledCB.isSelected() && drawThinStripesCB.isSelected()); setEnabledStripConfigs(enabledCB.isSelected()); } @@ -174,7 +196,7 @@ stripConfigsOpPanel.setEnabled(enabled); } - void save(){ + void save() { updateModeConfigIgnoreLineRegex(); stripConfigsTable.save(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |