Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved color property from channel to signal element, to make it chang…

…eable for all signal elements, not only digital signals.
  • Loading branch information...
commit 5c9badd88eb8ac7955a30d31c4365c332c9c08fa 1 parent 0fb1e42
@jawi authored
View
16 api/src/main/java/nl/lxtreme/ols/api/data/Channel.java
@@ -21,7 +21,6 @@
package nl.lxtreme.ols.api.data;
-import java.awt.*;
import java.util.*;
import nl.lxtreme.ols.api.data.annotation.*;
@@ -56,13 +55,6 @@
Collection<Annotation<?>> getAnnotations();
/**
- * Returns the color signals should be drawn in.
- *
- * @return the a signal color, never <code>null</code>.
- */
- Color getColor();
-
- /**
* Returns the index of this channel.
*
* @return a channel index, >= 0 && < {@value #MAX_CHANNELS}.
@@ -104,14 +96,6 @@
boolean isEnabled();
/**
- * Sets color for this channel.
- *
- * @param aColor
- * the color to set.
- */
- void setColor( final Color aColor );
-
- /**
* Sets enabled to the given value.
*
* @param aEnabled
View
33 client.project/src/main/java/nl/lxtreme/ols/client/project/impl/ChannelImpl.java
@@ -21,9 +21,6 @@
package nl.lxtreme.ols.client.project.impl;
-import static nl.lxtreme.ols.util.ColorUtils.*;
-
-import java.awt.*;
import java.beans.*;
import java.util.*;
import java.util.List;
@@ -43,15 +40,12 @@
private static final int MAX_CHANNELS = Ols.MAX_CHANNELS;
- private static final Color DEFAULT_COLOR = parseColor( "7bf9dd" );
-
// VARIABLES
private final int index;
private final int mask;
private String label;
- private Color color;
private boolean enabled;
private final List<Annotation<?>> annotations;
@@ -77,7 +71,6 @@ public ChannelImpl( final Channel aChannel )
this.index = aChannel.getIndex();
this.mask = aChannel.getMask();
this.label = aChannel.getLabel();
- this.color = aChannel.getColor();
this.enabled = aChannel.isEnabled();
this.annotations = new CopyOnWriteArrayList<Annotation<?>>( aChannel.getAnnotations() );
@@ -101,7 +94,6 @@ public ChannelImpl( final int aChannelIdx )
this.index = aChannelIdx;
this.mask = ( int )( 1L << aChannelIdx );
this.label = null;
- this.color = DEFAULT_COLOR;
this.enabled = true;
this.annotations = new CopyOnWriteArrayList<Annotation<?>>();
@@ -189,15 +181,6 @@ public boolean equals( final Object aObject )
* {@inheritDoc}
*/
@Override
- public Color getColor()
- {
- return this.color;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public int getIndex()
{
return this.index;
@@ -267,22 +250,6 @@ public void removePropertyChangeListener( final PropertyChangeListener aListener
* {@inheritDoc}
*/
@Override
- public void setColor( final Color aColor )
- {
- if ( aColor == null )
- {
- throw new IllegalArgumentException( "Color cannot be null!" );
- }
- Color oldColor = this.color;
- this.color = aColor;
-
- this.propertyChangeSupport.fireIndexedPropertyChange( "channelColor", this.index, oldColor, aColor );
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public void setEnabled( final boolean aEnabled )
{
boolean oldEnabled = this.enabled;
View
2  client/src/main/java/nl/lxtreme/ols/client/signaldisplay/model/SignalDiagramModel.java
@@ -245,7 +245,7 @@ public void addPropertyChangeListener( final PropertyChangeListener aListener )
*/
public SignalElement findSignalElement( final Point aPoint )
{
- final SignalElement[] elements = getSignalElementManager().getSignalElements( aPoint.y, aPoint.y + 1,
+ final SignalElement[] elements = getSignalElementManager().getSignalElements( aPoint.y, 1,
SignalElementMeasurer.LOOSE_MEASURER );
if ( elements.length == 0 )
{
View
48 client/src/main/java/nl/lxtreme/ols/client/signaldisplay/signalelement/SignalElement.java
@@ -59,6 +59,7 @@
private Channel channel;
/** the group we belong to, should always be non-null. */
private ElementGroup group;
+ private Color color;
private int height;
private int yPosition;
@@ -103,6 +104,7 @@ public static SignalElement createAnalogScopeElement( final ElementGroup aGroup
final SignalElement channelElement = new SignalElement( SignalElementType.ANALOG_SIGNAL, aGroup.getMask() );
channelElement.group = aGroup;
channelElement.height = UIManager.getInt( ANALOG_SCOPE_HEIGHT );
+ channelElement.color = getUIManagerValue( CHANNEL_DEFAULT_COLOR, Color.CYAN );
return channelElement;
}
@@ -121,13 +123,9 @@ public static SignalElement createDigitalSignalElement( final Channel aChannel,
channelElement.channel = aChannel;
channelElement.group = aGroup;
channelElement.height = UIManager.getInt( CHANNEL_HEIGHT );
+ channelElement.color = getUIManagerValue( CHANNEL_DEFAULT_COLOR, Color.CYAN );
channelElement.signalHeight = UIManager.getInt( DIGITAL_SIGNAL_HEIGHT );
- String string = UIManager.getString( SIGNALVIEW_SIGNAL_ALIGNMENT );
- if ( string == null )
- {
- string = "CENTER";
- }
- channelElement.alignment = SignalAlignment.valueOf( string );
+ channelElement.alignment = SignalAlignment.valueOf( getUIManagerValue( SIGNALVIEW_SIGNAL_ALIGNMENT, "CENTER" ) );
return channelElement;
}
@@ -145,6 +143,7 @@ public static SignalElement createGroupSummaryElement( final ElementGroup aGroup
final SignalElement channelElement = new SignalElement( SignalElementType.GROUP_SUMMARY, aGroup.getMask() );
channelElement.group = aGroup;
channelElement.height = UIManager.getInt( GROUP_SUMMARY_HEIGHT );
+ channelElement.color = getUIManagerValue( CHANNEL_DEFAULT_COLOR, Color.CYAN );
return channelElement;
}
@@ -162,10 +161,29 @@ public static SignalElement createSignalGroupElement( final ElementGroup aGroup
final SignalElement channelElement = new SignalElement( SignalElementType.SIGNAL_GROUP, aGroup.getMask() );
channelElement.group = aGroup;
channelElement.height = UIManager.getInt( SIGNAL_GROUP_HEIGHT );
+ channelElement.color = getUIManagerValue( CHANNEL_DEFAULT_COLOR, Color.CYAN );
return channelElement;
}
/**
+ * @param aKey
+ * the key to lookup, cannot be <code>null</code>.
+ * @param aDefault
+ * the default value to return in case the requested value is absent.
+ * @return a value, never <code>null</code>.
+ */
+ @SuppressWarnings( "unchecked" )
+ private static <TYPE> TYPE getUIManagerValue( final String aKey, final TYPE aDefault )
+ {
+ Object value = UIManager.get( aKey );
+ if ( ( value == null ) || !( aDefault.getClass().isAssignableFrom( value.getClass() ) ) )
+ {
+ return aDefault;
+ }
+ return ( TYPE )value;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -234,14 +252,7 @@ public Channel getChannel()
*/
public Color getColor()
{
- if ( this.channel != null )
- {
- return this.channel.getColor();
- }
- else
- {
- return this.group.getColor();
- }
+ return this.color;
}
/**
@@ -483,14 +494,11 @@ public boolean isSignalGroup()
*/
public void setColor( final Color aColor )
{
- if ( this.channel != null )
- {
- this.channel.setColor( aColor );
- }
- else
+ if ( aColor == null )
{
- this.group.setColor( aColor );
+ throw new IllegalArgumentException( "Color cannot be null!" );
}
+ this.color = aColor;
}
/**
View
12 ...src/main/java/nl/lxtreme/ols/client/signaldisplay/signalelement/SignalElementManager.java
@@ -24,11 +24,13 @@
import static nl.lxtreme.ols.client.signaldisplay.signalelement.SignalElement.*;
import java.util.*;
+import javax.swing.*;
import javax.swing.event.*;
import nl.lxtreme.ols.api.*;
import nl.lxtreme.ols.api.data.*;
import nl.lxtreme.ols.client.signaldisplay.*;
+import nl.lxtreme.ols.client.signaldisplay.laf.*;
import nl.lxtreme.ols.client.signaldisplay.signalelement.ISignalElementChangeListener.*;
@@ -300,6 +302,8 @@ public void dataModelChanged( final DataSet aCapturedData )
final int yMin = aY;
final int yMax = aHeight + aY;
+ final int spacing = UIManager.getInt( UIManagerKeys.SIGNAL_ELEMENT_SPACING );
+
int yPos = 0;
for ( ElementGroup group : getGroups() )
{
@@ -323,7 +327,7 @@ public void dataModelChanged( final DataSet aCapturedData )
element.setYposition( yPos );
result.add( element );
}
- yPos += height;
+ yPos += height + spacing;
}
else if ( element.isDigitalSignal() && group.isShowDigitalSignals() )
{
@@ -334,7 +338,7 @@ else if ( element.isDigitalSignal() && group.isShowDigitalSignals() )
element.setYposition( yPos );
result.add( element );
}
- yPos += height;
+ yPos += height + spacing;
}
else if ( element.isGroupSummary() && group.isShowGroupSummary() )
{
@@ -344,7 +348,7 @@ else if ( element.isGroupSummary() && group.isShowGroupSummary() )
element.setYposition( yPos );
result.add( element );
}
- yPos += height;
+ yPos += height + spacing;
}
else if ( element.isAnalogSignal() && group.isShowAnalogSignal() )
{
@@ -354,7 +358,7 @@ else if ( element.isAnalogSignal() && group.isShowAnalogSignal() )
element.setYposition( yPos );
result.add( element );
}
- yPos += height;
+ yPos += height + spacing;
}
}
}
View
2  ols.distribution/src/main/config/ols.ui.defaults.cfg
@@ -1,6 +1,6 @@
# Generic
ols.background.color = 1E2126
-ols.channel.default.color = 7BF9DD
+ols.channel.default.color = 7BF9D3
ols.signal.element.spacer.height = 4
ols.analogscope.height = 96
ols.signalgroup.height = 20
View
20 test.util/src/main/java/nl/lxtreme/ols/test/data/project/StubChannel.java
@@ -21,7 +21,6 @@
package nl.lxtreme.ols.test.data.project;
-import java.awt.*;
import java.util.*;
import nl.lxtreme.ols.api.data.*;
@@ -38,7 +37,6 @@
private final int index;
private final int mask;
- private Color color;
private String label;
private boolean enabled;
@@ -99,15 +97,6 @@ public int compareTo( final Channel aChannel )
* {@inheritDoc}
*/
@Override
- public Color getColor()
- {
- return this.color;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public int getIndex()
{
return this.index;
@@ -153,15 +142,6 @@ public boolean isEnabled()
* {@inheritDoc}
*/
@Override
- public void setColor( final Color aColor )
- {
- this.color = aColor;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public void setEnabled( final boolean aEnabled )
{
this.enabled = aEnabled;
Please sign in to comment.
Something went wrong with that request. Please try again.