Skip to content

Commit 430d720

Browse files
committed
Removed additional settings
1 parent aeb7815 commit 430d720

File tree

7 files changed

+84
-44
lines changed

7 files changed

+84
-44
lines changed

CodenameOne/src/com/codename1/charts/views/LineChart.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float
349349
* @param renderer the series renderer
350350
*/
351351
public boolean isRenderPoints(SimpleSeriesRenderer renderer) {
352-
return ((XYSeriesRenderer) renderer).getPointStyle() != PointStyle.POINT;
352+
return renderer instanceof XYSeriesRenderer &&
353+
((XYSeriesRenderer) renderer).getPointStyle() != PointStyle.POINT;
353354
}
354355

355356
/**

CodenameOne/src/com/codename1/charts/views/ScatterChart.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
import java.util.List;
2727

2828

29-
/**
30-
* Renders discrete X/Y points without connecting lines.
31-
* <p>
32-
* Configure the marker style through {@link XYSeriesRenderer#setPointStyle} and
33-
* related options on the {@link XYMultipleSeriesRenderer}. As with other
34-
* charts, wrap the instance in a {@link com.codename1.charts.ChartComponent} to
35-
* place it on a form.
36-
*/
37-
public class ScatterChart extends XYChart {
29+
/**
30+
* Renders discrete X/Y points without connecting lines.
31+
* <p>
32+
* Configure the marker style through {@link XYSeriesRenderer#setPointStyle} and
33+
* related options on the {@link XYMultipleSeriesRenderer}. As with other
34+
* charts, wrap the instance in a {@link com.codename1.charts.ChartComponent} to
35+
* place it on a form.
36+
*/
37+
public class ScatterChart extends XYChart {
3838
/** The constant to identify this chart type. */
3939
public static final String TYPE = "Scatter";
4040
/** The default point shape size. */
@@ -203,7 +203,8 @@ public int getLegendShapeWidth(int seriesIndex) {
203203
*/
204204
public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
205205
int seriesIndex, Paint paint) {
206-
if (((XYSeriesRenderer) renderer).isFillPoints()) {
206+
if (renderer instanceof XYSeriesRenderer &&
207+
((XYSeriesRenderer) renderer).isFillPoints()) {
207208
paint.setStyle(Style.FILL);
208209
} else {
209210
paint.setStyle(Style.STROKE);

CodenameOne/src/com/codename1/components/Progress.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,17 @@ public void setDisposeOnCompletion(boolean disposeOnCompletion) {
137137
* {@inheritDoc}
138138
*/
139139
public void actionPerformed(ActionEvent evt) {
140-
NetworkEvent ev = (NetworkEvent) evt;
141-
if (ev.getConnectionRequest() == request) {
142-
if (disposeOnCompletion && ev.getProgressType() == NetworkEvent.PROGRESS_TYPE_COMPLETED) {
143-
dispose();
144-
return;
145-
}
146-
if (autoShow && !showing) {
147-
showing = true;
148-
showModeless();
140+
if(evt instanceof NetworkEvent) {
141+
NetworkEvent ev = (NetworkEvent) evt;
142+
if (ev.getConnectionRequest() == request) {
143+
if (disposeOnCompletion && ev.getProgressType() == NetworkEvent.PROGRESS_TYPE_COMPLETED) {
144+
dispose();
145+
return;
146+
}
147+
if (autoShow && !showing) {
148+
showing = true;
149+
showModeless();
150+
}
149151
}
150152
}
151153
}

CodenameOne/src/com/codename1/components/SliderBridge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static void bindProgress(final ConnectionRequest[] sources, final Slider
117117
*/
118118
public void actionPerformed(ActionEvent evt) {
119119
// PMD Fix (CollapsibleIfStatements): Collapse the nested source checks into one conditional.
120-
if (sources != null && !sourceVec.contains(evt.getSource())) {
120+
if (sources != null && !sourceVec.contains(evt.getSource()) || !(evt instanceof NetworkEvent)) {
121121
return;
122122
}
123123
NetworkEvent e = (NetworkEvent) evt;

CodenameOne/src/com/codename1/components/SplitPane.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -967,10 +967,12 @@ private class Divider extends Container {
967967
.each(new ComponentClosure() {
968968
@Override
969969
public void call(Component c) {
970-
if (collapseIcon != null) {
971-
((Label) c).setIcon(collapseIcon);
972-
} else {
973-
((Label) c).setMaterialIcon(getCollapseMaterialIcon());
970+
if(c instanceof Label) {
971+
if (collapseIcon != null) {
972+
((Label) c).setIcon(collapseIcon);
973+
} else {
974+
((Label) c).setMaterialIcon(getCollapseMaterialIcon());
975+
}
974976
}
975977
}
976978

@@ -990,13 +992,14 @@ public void actionPerformed(ActionEvent evt) {
990992
.each(new ComponentClosure() {
991993
@Override
992994
public void call(Component c) {
993-
if (expandIcon != null) {
994-
((Label) c).setIcon(expandIcon);
995-
} else {
996-
((Label) c).setMaterialIcon(getExpandMaterialIcon());
995+
if(c instanceof Label) {
996+
if (expandIcon != null) {
997+
((Label) c).setIcon(expandIcon);
998+
} else {
999+
((Label) c).setMaterialIcon(getExpandMaterialIcon());
1000+
}
9971001
}
9981002
}
999-
10001003
})
10011004
.addActionListener(new ActionListener() {
10021005
public void actionPerformed(ActionEvent evt) {

CodenameOne/src/com/codename1/facebook/FaceBookAccess.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,19 @@ public void getPost(String postId, final Post post, final ActionListener callbac
513513
getFaceBookObject(postId, new ActionListener() {
514514

515515
public void actionPerformed(ActionEvent evt) {
516-
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
517-
Hashtable t = (Hashtable) v.elementAt(0);
518-
if (post != null) {
519-
post.copy(t);
520-
}
521-
if (callback != null) {
522-
callback.actionPerformed(evt);
516+
final Object val = ((NetworkEvent) evt).getMetaData();;
517+
if(val instanceof Vector) {
518+
final Vector v = (Vector) val;
519+
final Object o = v.elementAt(0);
520+
if(o instanceof Hashtable) {
521+
final Hashtable t = (Hashtable) o;
522+
if (post != null) {
523+
post.copy(t);
524+
}
525+
if (callback != null) {
526+
callback.actionPerformed(evt);
527+
}
528+
}
523529
}
524530
}
525531
});
@@ -548,10 +554,15 @@ public void actionPerformed(ActionEvent evt) {
548554
getFaceBookObject(postId, new ActionListener() {
549555

550556
public void actionPerformed(ActionEvent evt) {
551-
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
552-
Hashtable t = (Hashtable) v.elementAt(0);
553-
post.copy(t);
554-
557+
final Object val = ((NetworkEvent) evt).getMetaData();
558+
if(val instanceof Vector) {
559+
final Vector v = (Vector) val;
560+
final Object o = v.elementAt(0);
561+
if(o instanceof Hashtable) {
562+
Hashtable t = (Hashtable) o;
563+
post.copy(t);
564+
}
565+
}
555566
}
556567
}, needAuth, false);
557568
if (err.size() > 0) {

maven/core-unittests/spotbugs-exclude.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,23 @@
9696
<Match>
9797
<Bug pattern="EI_EXPOSE_REP2"/>
9898
</Match>
99+
<Match>
100+
<Bug pattern="MS_EXPOSE_REP"/>
101+
</Match>
102+
<Match>
103+
<Bug pattern="EI_EXPOSE_STATIC_REP2"/>
104+
</Match>
105+
106+
107+
<!--
108+
This rule prevents Class.newInstance() which we generally avoid anyway.
109+
However, the solution is to use java.beans or reflection to create a class
110+
via its constructor. That's a problem since that API isn't available in
111+
Codename One.
112+
-->
113+
<Match>
114+
<Bug pattern="REFLC_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_CLASS"/>
115+
</Match>
99116

100117
<!-- Match>
101118
<Bug pattern="UI_INHERITANCE_UNSAFE_GETRESOURCE"/>
@@ -125,10 +142,15 @@
125142
<Bug pattern="ES_COMPARING_STRINGS_WITH_EQ" />
126143
</Match>
127144

128-
<!-- The API should return null when the value isn't found -->
145+
<!-- The class has too many casts like this to go over -->
146+
<Match>
147+
<Class name="~com\.codename1\.facebook\.FaceBookAccess.*" />
148+
<Bug pattern="BC_UNCONFIRMED_CAST" />
149+
</Match>
150+
151+
<!-- The API isThemeConstant should return null when the value isn't found -->
129152
<Match>
130-
<Class name="~com\.codename1\.plaf\.UIManager" />
131-
<Method name="isThemeConstant" />
153+
<Class name="~com\.codename1\.plaf\.UIManager.*" />
132154
<Bug pattern="NP_BOOLEAN_RETURN_NULL" />
133155
</Match>
134156

0 commit comments

Comments
 (0)