Add range request methods to TreeSelectionI and MapContainer in order to avoid repeated calculations and make code more legible

Issue #289 new
Christopher Keil repo owner created an issue

USE CASE: WHAT DO YOU WANT TO DO?

Retrieve information about selection range or view range (boundaries, size, index within range) from selection or view objects respectively.

STEPS TO REPRODUCE AN ISSUE (OR TRIGGER A NEW FEATURE)

N/A

CURRENT BEHAVIOR

In order to check whether an index is selected or within view range (or similar operations regarding ranges) a developer currently has to manually calculate a range size or check for indices being within range boundaries (e.g. maxIndex - minIndex + 1; or minSelected <= index <= maxSelected)

EXPECTED BEHAVIOR

Simple, well-named functions are available for TreeSelection or MapContainer objects which make code more legible and focus calculations/ checks in one place where they can be unit-tested and debugged if necessary.

DEVELOPERS ONLY SECTION

SUGGESTED CHANGE (Pseudocode optional)

Implement applicable methods such that code outside of selection/ MapContainer objects for example looks like

geneIndex = ymap.getIndex(yPixel)
arrayIndex = xmap.getIndex(xPixel)

boolean <-- geneSelection.isInSelectionRange(geneIndex) && arraySelection.isInSelectionRange(arrayIndex)

instead of

geneSelection.getMinIndex() <= ymap.getIndex(yPixel) && geneSelection.getMaxIndex() >= ymap.getIndex(yPixel) && arraySelection.getMinIndex() <= xmap.getIndex(xPixel)  && arraySelection.getMaxIndex() >= xmap.getIndex(xPixel)

FILES AFFECTED (where the changes will be implemented) - developers only

TreeSelection classes, MapContainer + all files that repeatedly use specific calculations to get selection or view ranges (e.g. LabelView, IMV)

LEVEL OF EFFORT - developers only

minor (should be easy to find places via search).

COMMENTS

First, check if such methods already partially exist!

Replacing old code with the methods should be done where you can easily find it and otherwise on the go in the future. The issue is considered fixed if methods for range checks/ range sizes have been implemented in TreeSelection and MapContainer.

Comments (6)

  1. Log in to comment