Skip to content

Commit

Permalink
Massive cleanup of code; pushed more implementations down to private …
Browse files Browse the repository at this point in the history
…packages, making more (re)use of interfaces.
  • Loading branch information
J.W. Janssen committed Jan 25, 2012
1 parent d6e1cc9 commit a1061d3
Show file tree
Hide file tree
Showing 82 changed files with 2,898 additions and 2,814 deletions.
8 changes: 8 additions & 0 deletions api/src/main/java/nl/lxtreme/ols/api/UserSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public interface UserSettings extends Serializable, Iterable<Map.Entry<String, O
*/
public void put( String aName, String aValue );

/**
* Allows all given map of settings to be copied to this user settings.
*
* @param aSettings
* the map with settings to copy, cannot be <code>null</code>.
*/
public void putAll( Map<?, ?> aSettings );

/**
* Associates the given boolean value to the given name.
*
Expand Down
8 changes: 5 additions & 3 deletions api/src/main/java/nl/lxtreme/ols/api/data/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@


import java.awt.*;
import java.util.*;

import nl.lxtreme.ols.api.data.annotation.*;


/**
* Denotes a single channel in the data set.
*/
public interface Channel
public interface Channel extends Comparable<Channel>
{
// METHODS

Expand All @@ -49,9 +50,10 @@ public interface Channel
/**
* Returns all available annotations for this channel.
*
* @return a copy of all annotations, never <code>null</code>.
* @return an immutable collection of this channel's annotations, never
* <code>null</code>, never <code>null</code>.
*/
Annotation<?>[] getAnnotations();
Collection<Annotation<?>> getAnnotations();

/**
* Returns the color signals should be drawn in.
Expand Down
9 changes: 8 additions & 1 deletion api/src/main/java/nl/lxtreme/ols/api/data/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Defines a cursor, which is a temporary marker in time defined somewhere on
* the captured data.
*/
public interface Cursor
public interface Cursor extends Cloneable
{
// METHODS

Expand All @@ -37,6 +37,13 @@ public interface Cursor
*/
void clear();

/**
* Creates a clone of this cursor.
*
* @return an exact copy of this cursor.
*/
Cursor clone();

/**
* Returns the cursor color.
*
Expand Down
18 changes: 13 additions & 5 deletions api/src/main/java/nl/lxtreme/ols/api/data/DataContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public long getAbsoluteLength()
*/
public Channel[] getAllChannels()
{
return this.projectManager.getCurrentProject().getChannels();
return getCurrentDataSet().getChannels();
}

/**
Expand Down Expand Up @@ -466,7 +466,7 @@ public boolean isCursorPositionSet( final int aCursorIdx )
*/
public boolean isCursorsEnabled()
{
return this.projectManager.getCurrentProject().isCursorsEnabled();
return getCurrentDataSet().isCursorsEnabled();
}

/**
Expand Down Expand Up @@ -542,7 +542,7 @@ public void setChannelLabels( final String[] aLabels )
*/
public void setCursorEnabled( final boolean aCursorEnabled )
{
this.projectManager.getCurrentProject().setCursorsEnabled( aCursorEnabled );
getCurrentDataSet().setCursorsEnabled( aCursorEnabled );
}

/**
Expand Down Expand Up @@ -600,14 +600,22 @@ protected long calculateTimeOffset( final long aTime )
*/
private AcquisitionResult getAcquisitionData()
{
return this.projectManager.getCurrentProject().getCapturedData();
return getCurrentDataSet().getCapturedData();
}

/**
* @return
*/
private DataSet getCurrentDataSet()
{
return this.projectManager.getCurrentProject().getDataSet();
}

/**
* @return the cursorPositions
*/
private Cursor[] getCursors()
{
return this.projectManager.getCurrentProject().getCursors();
return getCurrentDataSet().getCursors();
}
}
91 changes: 91 additions & 0 deletions api/src/main/java/nl/lxtreme/ols/api/data/DataSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* OpenBench LogicSniffer / SUMP project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
* Copyright (C) 2006-2010 Michael Poppitz, www.sump.org
* Copyright (C) 2010-2012 J.W. Janssen, www.lxtreme.nl
*/
package nl.lxtreme.ols.api.data;


import nl.lxtreme.ols.api.acquisition.*;


/**
* Denotes a set of data, including the acquisition result, the channels and the
* cursors.
*/
public interface DataSet
{
// METHODS

/**
* Returns the captured data of this project.
*
* @return a captured data, can be <code>null</code>.
*/
public AcquisitionResult getCapturedData();

/**
* Returns a single channel.
*
* @param aIndex
* the channel index, >= 0 && <
* {@link AcquisitionResult#getChannels()}.
* @return an array of channels, never <code>null</code>.
*/
public Channel getChannel( int aIndex );

/**
* Returns the channels of this project.
*
* @return an array of channels, never <code>null</code>.
*/
public Channel[] getChannels();

/**
* Returns a single cursor
*
* @param aIndex
* the index of the cursor to retrieve, >= 0.
*/
public Cursor getCursor( int aIndex );

/**
* Returns the available cursors of this project.
*
* @return an array of cursors, never <code>null</code>.
*/
public Cursor[] getCursors();

/**
* Returns whether or not cursors are enabled.
*
* @return <code>true</code> if cursors are enabled, <code>false</code>
* otherwise.
*/
public boolean isCursorsEnabled();

/**
* Sets whether or not cursors are enabled.
*
* @param aEnabled
* <code>true</code> if cursors are enabled, <code>false</code>
* otherwise.
*/
public void setCursorsEnabled( final boolean aEnabled );

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import javax.swing.*;

import nl.lxtreme.ols.api.data.project.*;
import nl.lxtreme.ols.api.data.*;


/**
Expand All @@ -39,7 +39,7 @@ public interface Exporter
/**
* Exports the given data container to the given writer.
*
* @param aProject
* @param aDataSet
* the current project with all data to export, can never be
* <code>null</code>;
* @param aComponent
Expand All @@ -52,7 +52,7 @@ public interface Exporter
* @throws IOException
* in case of I/O problems.
*/
void export( final Project aProject, final JComponent aComponent, final OutputStream aStream ) throws IOException;
void export( final DataSet aDataSet, final JComponent aComponent, final OutputStream aStream ) throws IOException;

/**
* Returns the file extensions supported by this exporter.
Expand Down
Loading

0 comments on commit a1061d3

Please sign in to comment.