private VARNAConfig _conf = new VARNAConfig();
- private ArrayList<InterfaceVARNAListener> _VARNAListeners = new ArrayList<InterfaceVARNAListener>();
+ private ArrayList<InterfaceVARNAListener> _VARNAListeners = new ArrayList<>();
- private ArrayList<InterfaceVARNASelectionListener> _selectionListeners = new ArrayList<InterfaceVARNASelectionListener>();
+ private ArrayList<InterfaceVARNASelectionListener> _selectionListeners = new ArrayList<>();
- private ArrayList<InterfaceVARNARNAListener> _RNAListeners = new ArrayList<InterfaceVARNARNAListener>();
+ private ArrayList<InterfaceVARNARNAListener> _RNAListeners = new ArrayList<>();
- private ArrayList<InterfaceVARNABasesListener> _basesListeners = new ArrayList<InterfaceVARNABasesListener>();
+ private ArrayList<InterfaceVARNABasesListener> _basesListeners = new ArrayList<>();
UndoManager _manager;
private BaseList _selectedBases = new BaseList("selection");
- private ArrayList<ModeleBase> _backupSelection = new ArrayList<ModeleBase>();
+ private ArrayList<ModeleBase> _backupSelection = new ArrayList<>();
private Integer _nearestBase = null;
private void init()
{
_popup.buildPopupMenu();
- this.add(_popup);
+ // BH 2019.05.16 *add* a popup menu? SwingJS issue here -- actually does ADD
+ // the menu
+ // this.add(_popup);
setBackground(VARNAConfig.DEFAULT_BACKGROUND_COLOR);
_manager = new UndoManager();
_manager.setLimit(10000);
public void undo()
{
if (_manager.canUndo())
+ {
_manager.undo();
+ }
}
public void redo()
{
if (_manager.canRedo())
+ {
_manager.redo();
+ }
}
/**
double y, double margin)
{
Dimension d = g2D.getStringDimension(res);
- x -= (double) d.width / 2.0;
- y += (double) d.height / 2.0;
+ x -= d.width / 2.0;
+ y += d.height / 2.0;
g2D.setColor(Color.GRAY);
g2D.setSelectionStroke();
g2D.drawRect((x - margin), (y - d.height - margin),
{
double distance, coef;
if (j - i == 1)
+ {
coef = getBPHeightIncrement() * 1.75;
+ }
else
+ {
coef = getBPHeightIncrement();
+ }
distance = dest.x - orig.x;
switch (_conf._mainBPStyle)
{
return getHighlightedVersion(c1, c2);
}
else
+ {
return initialColor;
+ }
}
public static Point2D.Double computeExcentricUnitVector(int i,
{
Rectangle2D.Double rnabbox = getExtendedRNABBox();
double scaleFactor = Math.min(
- (double) bbox.width / (double) rnabbox.width,
- (double) bbox.height / (double) rnabbox.height);
+ bbox.width / rnabbox.width,
+ bbox.height / rnabbox.height);
// Use it to get an estimate of the font size for numbers ...
float newFontSize = Math.max(1,
rnabbox.width += newFontSize;
// Now, compute the final scaling factor and corresponding font size
- scaleFactor = Math.min((double) bbox.width / (double) rnabbox.width,
- (double) bbox.height / (double) rnabbox.height);
+ scaleFactor = Math.min(bbox.width / rnabbox.width,
+ bbox.height / rnabbox.height);
if (localView)
{
if (_conf._autoFit)
+ {
setScaleFactor(scaleFactor);
+ }
scaleFactor = getScaleFactor();
}
return scaleFactor;
double result = VARNAConfig.DEFAULT_COLOR_MAP_FONT_SIZE
+ _conf._colorMapHeight;
if (!_conf._colorMapCaption.equals(""))
+ {
result += VARNAConfig.DEFAULT_COLOR_MAP_FONT_SIZE;
+ }
return result;
}
for (int i = 0; i < _conf._colorMapWidth; i++)
{
- double ratio = (((double) i) / ((double) _conf._colorMapWidth));
+ double ratio = ((i) / (_conf._colorMapWidth));
double val = v1 + (v2 - v1) * ratio;
g2D.setColor(_conf._cm.getColorForValue(val));
x = (xBase + scaleFactor * i);
yBase + scaleFactor * (_conf._colorMapHeight
+ (VARNAConfig.DEFAULT_COLOR_MAP_FONT_SIZE / 1.7)));
if (!_conf._colorMapCaption.equals(""))
+ {
g2D.drawStringCentered("" + _conf._colorMapCaption,
xBase + scaleFactor * _conf._colorMapWidth / 2.0,
yBase + scaleFactor
* (VARNAConfig.DEFAULT_COLOR_MAP_FONT_SIZE / 1.7
+ _conf._colorMapHeight));
+ }
}
_offY + (getScaleFactor() * (coordDebut.y - rnabbox.y)));
}
+ @Override
public void paintComponent(Graphics g)
{
paintComponent(g, false);
VueVARNAGraphics g2D = new SwingGraphics(g2);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- this.removeAll();
+ // BH 2019.05.16 *remove* the popup menu?
+ // this.removeAll();
super.paintComponent(g2);
renderComponent(g2D, transparentBackground, getScaleFactor());
if (isFocusOwner())
updateTitleHeight();
- if (!transparentBackground)
+ if (true || !transparentBackground)
{
g2D.setColor(_conf._backgroundColor);
g2D.fillRect(0, 0, getWidth(), getHeight());
}
else
{
- super.setBackground(new Color(0, 0, 0, 120));
+ g2D.setColor(new Color(0, 0, 0, 120));
+ // BH SwingJS not allowing this TODO -- fix alpha for background color
+ // super.setBackground(new Color(0, 0, 0, 120));
}
if (_debug || _drawBorder)
g2D.drawLine(linkOrigin.x, linkOrigin.y, linkDestination.x,
linkDestination.y);
for (int i : getSelection().getIndices())
+ {
drawBase(g2D, i, _realCoords, _realCenters,
scaleFactor * _RNA.BASE_RADIUS, scaleFactor, true);
+ }
}
if (_debug)
return false;
}
else
+ {
return _interpolator.isInterpolationInProgress();
+ }
}
/**
* In this array, we'll have for each indexes of each characters of the
* final super-structure, the RNA number which is own it.
*/
- ArrayList<Integer> array_rnaOwn = new ArrayList<Integer>();
+ ArrayList<Integer> array_rnaOwn = new ArrayList<>();
/**
* Generating super-structure sequences and structures...
public void emitWarning(String warning)
{
if (_conf._showWarnings)
+ {
JOptionPane.showMessageDialog(this, warning, "VARNA Warning",
JOptionPane.WARNING_MESSAGE);
+ }
}
public static void emitWarningStatic(Exception e, Component c)
* @param c
* New background color
*/
+ @Override
public void setBackground(Color c)
{
if (_conf != null)
*/
public void highlightSelectedBase(ModeleBase m)
{
- ArrayList<Integer> v = new ArrayList<Integer>();
+ ArrayList<Integer> v = new ArrayList<>();
int sel = m.getIndex();
if (sel != -1)
{
*/
public void highlightSelectedStem(ModeleBase m)
{
- ArrayList<Integer> v = new ArrayList<Integer>();
+ ArrayList<Integer> v = new ArrayList<>();
int sel = m.getIndex();
if (sel != -1)
{
public ArrayList<Integer> getBasesInRectangleDiff(Rectangle recIn,
Rectangle recOut)
{
- ArrayList<Integer> result = new ArrayList<Integer>();
+ ArrayList<Integer> result = new ArrayList<>();
for (int i = 0; i < _realCoords.length; i++)
{
if (recIn.contains(_realCoords[i]) ^ recOut.contains(_realCoords[i]))
+ {
result.add(i);
+ }
}
return result;
}
public ArrayList<Integer> getBasesInRectangle(Rectangle rec)
{
- ArrayList<Integer> result = new ArrayList<Integer>();
+ ArrayList<Integer> result = new ArrayList<>();
for (int i = 0; i < _realCoords.length; i++)
{
if (rec.contains(_realCoords[i]))
+ {
result.add(i);
+ }
}
return result;
}
public void setSelectionRectangle(Rectangle rec)
{
- ArrayList<Integer> result = new ArrayList<Integer>();
+ ArrayList<Integer> result = new ArrayList<>();
if (_selectionRectangle != null)
{
result = getBasesInRectangleDiff(_selectionRectangle, rec);
public void toggleSelection(int i)
{
if (isInSelection(i))
+ {
removeFromSelection(i);
+ }
else
+ {
addToSelection(i);
+ }
}
public void toggleSelection(Collection<? extends Integer> indices)
{
int i = getNearestBaseIndex(x, y, always, onlyPaired);
if (i == -1)
+ {
return null;
+ }
return getRNA().get_listeBases().get(i);
}