Skip to content

Commit

Permalink
Merge pull request #294 from JieD/master
Browse files Browse the repository at this point in the history
Set paint rate (#286)
  • Loading branch information
VWoeltjen committed Jun 10, 2014
2 parents 287a458 + 69c4b8e commit a274534
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
31 changes: 26 additions & 5 deletions mctcore/src/main/java/gov/nasa/arc/mct/gui/FeedView.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import gov.nasa.arc.mct.components.AbstractComponent;
import gov.nasa.arc.mct.components.FeedProvider;
import gov.nasa.arc.mct.services.component.ViewInfo;

import gov.nasa.arc.mct.util.property.MCTProperties;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -36,10 +37,13 @@
import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;


import javax.swing.SwingWorker;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This is the super class for feed displays. All feed views are painted by periodic feed data
Expand All @@ -49,10 +53,12 @@
* <li>Override {@link #updateFromFeed(Map)} to refresh the view with the incoming data set.</li>
* </ul>
*/
public abstract class FeedView extends View {
public abstract class FeedView extends View {
private static final Logger logger = LoggerFactory.getLogger(FeedView.class);
private static final long serialVersionUID = 1L;
private static final int PAINT_RATE = 250; // paint rate in milliseconds
private static final FeedRenderingPool feedPool = new FeedRenderingPool(PAINT_RATE);
private static final int PAINT_RATE = getPaintRate();
private static final FeedRenderingPool feedPool = new FeedRenderingPool(PAINT_RATE);

/**
* The maximum number of data points that are returned from a data request. This will cause the
* requests to be split into a number of requests that the client will need to merge as they are completed.
Expand Down Expand Up @@ -420,5 +426,20 @@ public static Set<FeedView> getAllActiveFeedManifestations() {

static void resetLastDataRequestTimeToCurrentTime() {
feedPool.resetLastDataRequestTimeToCurrentTime();
}

/**
* get Paint Rate from property file, or use the default value 250 milliseconds
* If the user input is in wrong format, log the error and use the default value
* @return paint rate
*/
private static int getPaintRate() {
int paint_rate = 250;
try {
paint_rate = Integer.parseInt(MCTProperties.DEFAULT_MCT_PROPERTIES.getProperty("mct.feed.paint.rate", "250"));
} catch (NumberFormatException ex) {
logger.warn("Wrong input format for mct.feed.paint.rate. Need to input an integer. Defaulting to 250 ms.");
}
return paint_rate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ default.user.group=Users
# Menu names can be overridden here
mct.menu.this=File

# Paint rate at which views of data feeds are refreshed, in milliseconds
mct.feed.paint.rate=250

# change the set of packages made available on the OSGI bootclass loader
org.osgi.framework.bootdelegation=javax.xml.bind, \
javax.accessibility,\
Expand Down

0 comments on commit a274534

Please sign in to comment.