/** * The <code>RGB2HMMD (int ir, int ig, int ib)</code> class is responsible for converting RGB * values to HMMD values * * @param ir - RED component * @param ig - GREEN component * @param ib - BLUE component * @return int[] - HMMD value of the pixle * @throws Exception * @author [email protected] */ private static int[] RGB2HMMD(int ir, int ig, int ib) throws Exception { int HMMD[] = new int[5]; float max = (float) Math.max(Math.max(ir, ig), Math.max(ig, ib)); float min = (float) Math.min(Math.min(ir, ig), Math.min(ig, ib)); float diff = (max - min); float sum = (float) ((max + min) / 2.); float hue = 0; if (diff == 0) hue = 0; else if (ir == max && (ig - ib) > 0) hue = 60 * (ig - ib) / (max - min); else if (ir == max && (ig - ib) <= 0) hue = 60 * (ig - ib) / (max - min) + 360; else if (ig == max) hue = (float) (60 * (2. + (ib - ir) / (max - min))); else if (ib == max) hue = (float) (60 * (4. + (ir - ig) / (max - min))); diff /= 2; HMMD[0] = (int) (hue); HMMD[1] = (int) (max); HMMD[2] = (int) (min); HMMD[3] = (int) (diff); HMMD[4] = (int) (sum); return (HMMD); }
@Test public void max3float() { assertEquals(0.3f, Math.max(0.1f, 0.2f, 0.3f), 0.0); assertEquals(0.31f, Math.max(0.31f, 0.2f, 0.3f), 0.0); assertEquals(0.5f, Math.max(0.1f, 0.5f, 0.3f), 0.0); assertEquals(0.5f, Math.max(-10.1f, 0.5f, -0.3f), 0.0); }
@Test public void max4int() { assertEquals(5, Math.max(-10, 5, 3, 1)); assertEquals(10, Math.max(10, 5, 3, 1)); assertEquals(13, Math.max(-10, 5, 13, 1)); assertEquals(15, Math.max(-10, 5, 3, 15)); }
@Override public Vector getMaximumPoint() { return new Vector( Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()), Math.max(pos1.getZ(), pos2.getZ())); }
/** * Find all News entities with a specific property value. * * @param propertyName the name of the News property to query * @param value the property value to match * @param rowStartIdxAndCount Optional int varargs. rowStartIdxAndCount[0] specifies the the row * index in the query result-set to begin collecting the results. rowStartIdxAndCount[1] * specifies the the maximum number of results to return. * @return List<News> found by query */ @SuppressWarnings("unchecked") public List<News> findByProperty( String propertyName, final Object value, final int... rowStartIdxAndCount) { LogUtil.log( "finding News instance with property: " + propertyName + ", value: " + value, Level.INFO, null); try { final String queryString = "select model from News model where model." + propertyName + "= :propertyValue"; Query query = entityManager.createQuery(queryString); query.setParameter("propertyValue", value); if (rowStartIdxAndCount != null && rowStartIdxAndCount.length > 0) { int rowStartIdx = Math.max(0, rowStartIdxAndCount[0]); if (rowStartIdx > 0) { query.setFirstResult(rowStartIdx); } if (rowStartIdxAndCount.length > 1) { int rowCount = Math.max(0, rowStartIdxAndCount[1]); if (rowCount > 0) { query.setMaxResults(rowCount); } } } return query.getResultList(); } catch (RuntimeException re) { LogUtil.log("find by property name failed", Level.SEVERE, re); throw re; } }
@Override protected final void addMovementCells( SheetGraphics graphics, PdfPTable table, HealthLevelType level, int painTolerance, IGenericTraitCollection collection) { int woundPenalty = getPenalty(level, painTolerance); int dex = collection.getTrait(AttributeType.Dexterity).getCurrentValue(); int str = collection.getTrait(AttributeType.Strength).getCurrentValue(); int athletics = collection.getTrait(AbilityType.Athletics).getCurrentValue(); // minimum move is 1, minimum dash is 2, minimum jump h/v, swim, & climb is unknown int move = Math.max(dex + woundPenalty + mobilityPenalty, 1); int dash = Math.max(dex + woundPenalty + mobilityPenalty + 6, 2); int verticalJump = str + athletics + woundPenalty + mobilityPenalty; int horizontalJump = verticalJump * 2; table.addCell(createMovementCell(graphics, move, 1)); addSpaceCells(graphics, table, 1); table.addCell(createMovementCell(graphics, dash, 2)); addSpaceCells(graphics, table, 1); table.addCell(createMovementCell(graphics, horizontalJump, 0)); table.addCell(createMovementCell(graphics, verticalJump, 0)); }
/** * Formats a list of edits in unified diff format * * @param edits some differences which have been calculated between A and B * @param a the text A which was compared * @param b the text B which was compared * @throws IOException */ public void format(final EditList edits, final RawText a, final RawText b) throws IOException { for (int curIdx = 0; curIdx < edits.size(); ) { Edit curEdit = edits.get(curIdx); final int endIdx = findCombinedEnd(edits, curIdx); final Edit endEdit = edits.get(endIdx); int aCur = Math.max(0, curEdit.getBeginA() - context); int bCur = Math.max(0, curEdit.getBeginB() - context); final int aEnd = Math.min(a.size(), endEdit.getEndA() + context); final int bEnd = Math.min(b.size(), endEdit.getEndB() + context); writeHunkHeader(aCur, aEnd, bCur, bEnd); while (aCur < aEnd || bCur < bEnd) { if (aCur < curEdit.getBeginA() || endIdx + 1 < curIdx) { writeContextLine(a, aCur); if (isEndOfLineMissing(a, aCur)) out.write(noNewLine); aCur++; bCur++; } else if (aCur < curEdit.getEndA()) { writeRemovedLine(a, aCur); if (isEndOfLineMissing(a, aCur)) out.write(noNewLine); aCur++; } else if (bCur < curEdit.getEndB()) { writeAddedLine(b, bCur); if (isEndOfLineMissing(b, bCur)) out.write(noNewLine); bCur++; } if (end(curEdit, aCur, bCur) && ++curIdx < edits.size()) curEdit = edits.get(curIdx); } } }
/** * Convert all pixels to grayscale from RGB or RGBA. Do not call this method if the pixels are not * currently RGB or RGBA. * * @param normalize <code>true</code> to normalize the image after converting to grayscale, such * that the darkest pixel in the image is all black and the lightest pixel in the image is all * white. */ public final void toGrayScale(boolean normalize) { if (npix == 0) { return; } if (!normalize) { for (int i = 0; i < npix; i++) { pixels[i] = rgbToGrayScale(pixels[i]); } } else { int pix; pixels[0] = pix = rgbToGrayScale(pixels[0]); int min = pix, max = pix; for (int i = 1; i < npix; i++) { pixels[i] = pix = rgbToGrayScale(pixels[i]); min = Math.min(min, pix); max = Math.max(max, pix); } int range = max - min; if (range < 1) { for (int i = 0; i < npix; i++) { pixels[i] = 255; } } else { for (int i = 0; i < npix; i++) { pixels[i] = Math.min(255, Math.max(0, ((pixels[i] - min) * 255) / range)); } } } }
/*12. 求二叉树中节点的最大距离 具体分析(http://blog.csdn.net/lalor/article/details/7626678) 即二叉树中相距最远的两个节点之间的距离。 递归解法: (1)如果二叉树为空,返回0,同时记录左子树和右子树的深度,都为0 (2)如果二叉树不为空,最大距离要么是左子树中的最大距离,要么是右子树中的最大距离, 要么是左子树节点中到根节点的最大距离+右子树节点中到根节点的最大距离, 同时记录左子树和右子树节点中到根节点的最大距离。 */ public static int getMaxDistance(TreeNode node, int maxLeft, int maxRight) { // maxLeft, 左子树中的节点距离左子树根节点的最远距离 // maxRight, 右子树中的节点距离左子树根节点的最远距离 if (node == null) { maxLeft = 0; maxRight = 0; return 0; } int maxLL = 0, maxLR = 0, maxRL = 0, maxRR = 0; int maxDistLeft, maxDistRight; if (node.left != null) { maxDistLeft = getMaxDistance(node.left, maxLL, maxLR); maxLeft = Math.max(maxLL, maxLR) + 1; } else { maxDistLeft = 0; maxLeft = 0; } if (node.right != null) { maxDistRight = getMaxDistance(node.right, maxRL, maxRR); maxRight = Math.max(maxRL, maxRR) + 1; } else { maxDistRight = 0; maxRight = 0; } int result = Math.max(Math.max(maxDistLeft, maxDistRight), maxLeft + maxRight + 1); return result; }
@Override protected void render(boolean isTranslatable) { int yPos = 4; yPos += drawCenteredString(Lang.translate("Contents"), yPos); yPos += drawBlankLine() * 2; for (int i = 0; i < pages.size(); i++) { String pageTxt = Lang.translate("Page") + " " + pages.get(i); int x = PAGE_WIDTH - 4 - getStringWidth(pageTxt); int mY = drawTextLine(pageTxt, x, yPos); mY = Math.max(mY, drawTextBlock(contents.get(i), 4, yPos, x - 12)); int s = 0; List<String> splitStr = manual.fonts.listFormattedStringToWidth(contents.get(i), x - 12); int BORDER = 2; for (String s1 : splitStr) { s = Math.max(s, BORDER + getStringWidth(s1)); } int pw = manual.fonts.getStringWidth("."); if (s + pw < (x - BORDER)) { for (int nx = s; nx < (x - BORDER); nx += pw) { manual.fonts.drawString(".", nx, yPos, 0); } } yPos += mY; } }
public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) { return 0; } int len = prices.length; int min = prices[0]; int[] left_maxProfit = new int[len]; // compute the left profit. Store each value at left_maxProfit for (int i = 1; i < len; i++) { left_maxProfit[i] = Math.max(left_maxProfit[i - 1], prices[i] - min); min = Math.min(min, prices[i]); } // compute the right profit. int max = prices[len - 1]; int right_maxProfit = 0; int total_profit = left_maxProfit[len - 1]; for (int i = len - 2; i >= 0; i--) { right_maxProfit = Math.max(right_maxProfit, max - prices[i]); max = Math.max(max, prices[i]); total_profit = Math.max(total_profit, left_maxProfit[i] + right_maxProfit); } return total_profit; }
/** * Instantiates a new hud. * * @param u1 the u1 * @param u2 the u2 * @param stage the stage */ public HUD(Unit u1, Unit u2, FightStage stage) { super(0, 0); this.unit = u1; sign = stage.isLeft(u1) ? -1 : 1; this.stage = stage; if (battleStats == null) battleStats = FEResources.getTexture("gui_battleStats"); if (!CombatCalculator.shouldAttack(u1, u2, u1.getWeapon(), stage.getRange())) { hit = " -"; crit = " -"; dmg = " -"; } else { hit = String.format("%3d", Math.min(100, Math.max(CombatCalculator.hitRate(u1, u2), 0))); crit = String.format("%3d", Math.min(100, Math.max(u1.crit() - u2.dodge(), 0))); dmg = String.format( "%3d", Math.min(100, Math.max(CombatCalculator.calculatePreviewDamage(u1, u2), 0))); } renderDepth = FightStage.HUD_DEPTH; stage.addEntity( new ItemDisplay( FightStage.CENTRAL_AXIS + sign * 39 - 37, FightStage.FLOOR + 13, u1.getWeapon(), false)); }
private static ExecutorService startAlertClientService( SystemMain system, AtomicInteger jobCounter) { int configuredCount = Integer.valueOf( system.getConfiguration().getValue(SystemConfiguration.Property.CLIENT_THREADS)); int configuredTimeout = Integer.valueOf( system .getConfiguration() .getValue(SystemConfiguration.Property.CLIENT_CONNECT_TIMEOUT)); int threadPoolCount = Math.max(configuredCount, 2); int timeout = Math.max(10000, configuredTimeout); ExecutorService service = Executors.newFixedThreadPool( threadPoolCount, new ThreadFactory() { AtomicInteger id = new AtomicInteger(0); @Override public Thread newThread(Runnable r) { return new Thread(r, MessageFormat.format("alertclient-{0}", id.getAndIncrement())); } }); system.getServiceFactory().getMonitorService().startRecordingCounters(); for (int i = 0; i < threadPoolCount; i++) { service.submit( new Alerter(system.getServiceFactory().getAlertService(), timeout, jobCounter)); } return service; }
private static int parseByteSize(String size_str) { int idxOfKilo = Math.max(size_str.indexOf('k'), size_str.indexOf('K')); int idxOfMega = Math.max(size_str.indexOf('m'), size_str.indexOf('M')); if (idxOfKilo > 0) return Integer.parseInt(size_str.substring(0, idxOfKilo)) * 1024; else if (idxOfMega > 0) return Integer.parseInt(size_str.substring(0, idxOfMega)) * 1024 * 1024; else return Integer.parseInt(size_str); }
@Override protected ClickableArea[] clickableAreasForPoints( List<Float> points, List<Double> values, float yAxisValue, int seriesIndex, int startIndex) { int seriesNr = mDataset.getSeriesCount(); int length = points.size(); ClickableArea[] ret = new ClickableArea[length / 2]; float halfDiffX = getHalfDiffX(points, length, seriesNr); for (int i = 0; i < length; i += 2) { float x = points.get(i); float y = points.get(i + 1); if (mType == Type.STACKED || mType == Type.HEAPED) { ret[i / 2] = new ClickableArea( new RectF( x - halfDiffX, Math.min(y, yAxisValue), x + halfDiffX, Math.max(y, yAxisValue)), values.get(i), values.get(i + 1)); } else { float startX = x - seriesNr * halfDiffX + seriesIndex * 2 * halfDiffX; ret[i / 2] = new ClickableArea( new RectF( startX, Math.min(y, yAxisValue), startX + 2 * halfDiffX, Math.max(y, yAxisValue)), values.get(i), values.get(i + 1)); } } return ret; }
Point minimumSize(int wHint, int hHint, boolean flushCache) { Control[] children = _getChildren(); int width = 0, height = 0; for (int i = 0; i < children.length; i++) { Control child = children[i]; int index = 0; int count = 0; long /*int*/ list = OS.gtk_container_get_children(handle); if (list != 0) { count = OS.g_list_length(list); OS.g_list_free(list); } while (index < count) { if (items[index].control == child) break; index++; } if (index == count) { Rectangle rect = child.getBounds(); width = Math.max(width, rect.x + rect.width); height = Math.max(height, rect.y + rect.height); } else { Point size = child.computeSize(wHint, hHint, flushCache); width = Math.max(width, size.x); height = Math.max(height, size.y); } } return new Point(width, height); }
public long countTriplets(int minx, int maxx, int miny, int maxy, int minz, int maxz) { long ans = 0; int lim = 1 << 16; for (int x = minx; x <= maxx && x < lim; x++) { long miny2 = minz / x; if (x * miny2 < minz) miny2++; miny2 = Math.max(miny2, miny); long maxy2 = maxz / x; maxy2 = Math.min(maxy2, maxy); if (maxy2 >= miny2) ans += maxy2 - miny2 + 1; } for (int y = miny; y <= maxy && y < lim; y++) { long minx2 = minz / y; if (y * minx2 < minz) minx2++; minx2 = Math.max(minx2, minx); minx2 = Math.max(minx2, lim); long maxx2 = maxz / y; maxx2 = Math.min(maxx2, maxx); if (maxx2 >= minx2) ans += maxx2 - minx2 + 1; } return ans; }
public int largestRectangleArea(int[] height) { int area = 0, border; Stack<Node> heightStack = new Stack<Node>(); heightStack.push(new Node(-1, -1)); Node temNode; for (int i = 0; i < height.length; i++) { if (heightStack.peek().height < height[i]) { heightStack.push(new Node(height[i], i)); } else { temNode = heightStack.peek(); border = temNode.index; while (heightStack.peek().height > height[i]) { temNode = heightStack.pop(); area = Math.max((border - heightStack.peek().index) * temNode.height, area); } area = Math.max((i - heightStack.peek().index) * height[i], area); heightStack.push(new Node(height[i], i)); } } border = heightStack.peek().index; while (!heightStack.empty()) { Node tem = heightStack.pop(); if (heightStack.empty()) return area; area = Math.max(area, tem.height * (border - heightStack.peek().index)); } return area; }
private void preload(int from, int to) { int start; int end; if (from < to) { start = Math.max(lastEnd, from); end = to; } else { start = to; end = Math.min(lastStart, from); } end = Math.min(totalItemCount, end); start = Math.min(totalItemCount, Math.max(0, start)); if (from < to) { // Increasing for (int i = start; i < end; i++) { preloadAdapterPosition(this.preloadModelProvider.getPreloadItems(i), i, true); } } else { // Decreasing for (int i = end - 1; i >= start; i--) { preloadAdapterPosition(this.preloadModelProvider.getPreloadItems(i), i, false); } } lastStart = start; lastEnd = end; }
static String getBanDurationBreakdown(final Timestamp stamp) { if (stamp == null) return "Banned Forever"; final long millis = stamp.getTime() - System.currentTimeMillis(); if (millis < 0) return "Ban time left: 1 Minute"; long seconds = Math.max(1, TimeUnit.MILLISECONDS.toSeconds(millis)); final int minutesInSeconds = 60; final int hoursInSeconds = 60 * 60; final int daysInSeconds = 60 * 60 * 24; final long days = seconds / daysInSeconds; seconds -= days * daysInSeconds; final long hours = seconds / hoursInSeconds; seconds -= hours * hoursInSeconds; final long minutes = Math.max(1, seconds / minutesInSeconds); /* final long days = TimeUnit.MILLISECONDS.toDays(millis); millis -= TimeUnit.DAYS.toMillis(days); final long hours = TimeUnit.MILLISECONDS.toHours(millis); millis -= TimeUnit.HOURS.toMillis(hours); final long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) + 1;*/ final StringBuilder sb = new StringBuilder(64); sb.append("Ban time left: "); if (days > 0) { sb.append(days); sb.append(" Days "); } if (hours > 0) { sb.append(hours); sb.append(" Hours "); } if (minutes > 0) { sb.append(minutes); sb.append(" Minutes "); } return (sb.toString()); }
protected static void parseArgs(final String[] args) { int i = 0; while (i < args.length) { final String loopOptionKey = args[i]; switch (loopOptionKey) { case "-n": i += 1; SIZE = Math.max(1, Math.min(Integer.parseInt(args[i]), MAX_SOLUTIONS)); break; case "-t": i += 1; THRESHOLD = Math.max(1, Math.min(Integer.parseInt(args[i]), MAX_SOLUTIONS)); break; case "-w": i += 1; NUM_WORKERS = Integer.parseInt(args[i]); break; case "-s": i += 1; SOLUTIONS_LIMIT = Integer.parseInt(args[i]); break; case "-p": i += 1; final int priority = Integer.parseInt(args[i]); final int maxPriority = MessagePriority.values().length - 1; PRIORITIES = Math.max(1, Math.min(priority, maxPriority)); break; case "-debug": case "-verbose": debug = true; break; } i += 1; } }
private RECT getCharacterBounds(Set<Integer> characters, Set<BoundedTag> added) { RECT ret = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); boolean foundSomething = false; for (int c : characters) { Tag t = swf.getCharacter(c); RECT r = null; if (t instanceof BoundedTag) { BoundedTag bt = (BoundedTag) t; if (!added.contains(bt)) { added.add(bt); r = bt.getRect(added); added.remove(bt); } } if (r != null) { foundSomething = true; ret.Xmin = Math.min(r.Xmin, ret.Xmin); ret.Ymin = Math.min(r.Ymin, ret.Ymin); ret.Xmax = Math.max(r.Xmax, ret.Xmax); ret.Ymax = Math.max(r.Ymax, ret.Ymax); } } if (!foundSomething) { return new RECT(); } return ret; }
@Override public void convert(final RealComposite<T> input, final ARGBDoubleType output) { output.setZero(); for (int i = 0; i < argbs.length; ++i) { final double t = input.get(i).getRealDouble(); final ARGBDoubleType c = argbs[i]; final double a = c.getA(); final double r = output.getR() + a * c.getR() * t; final double g = output.getG() + a * c.getG() * t; final double b = output.getB() + a * c.getB() * t; output.setR(r); output.setG(g); output.setB(b); } final double r = output.getR(); final double g = output.getG(); final double b = output.getB(); // final double a = ( r + g + b ) / 3.0; final double a = Math.max(0, Math.min(1.0, Math.max(r, Math.max(g, b)))); // final double a = Math.max( r, Math.max( g, b ) ); output.set(a, r, g, b); }
public static int getMax(int c0, int c1) { return getColor( 1, Math.max(getRed(c0), getRed(c1)), Math.max(getGreen(c0), getGreen(c1)), Math.max(getBlue(c0), getBlue(c1))); }
/** * Find all News entities. * * @param rowStartIdxAndCount Optional int varargs. rowStartIdxAndCount[0] specifies the the row * index in the query result-set to begin collecting the results. rowStartIdxAndCount[1] * specifies the the maximum count of results to return. * @return List<News> all News entities */ @SuppressWarnings("unchecked") public List<News> findAll(final int... rowStartIdxAndCount) { LogUtil.log("finding all News instances", Level.INFO, null); try { final String queryString = "select model from News model"; Query query = entityManager.createQuery(queryString); if (rowStartIdxAndCount != null && rowStartIdxAndCount.length > 0) { int rowStartIdx = Math.max(0, rowStartIdxAndCount[0]); if (rowStartIdx > 0) { query.setFirstResult(rowStartIdx); } if (rowStartIdxAndCount.length > 1) { int rowCount = Math.max(0, rowStartIdxAndCount[1]); if (rowCount > 0) { query.setMaxResults(rowCount); } } } return query.getResultList(); } catch (RuntimeException re) { LogUtil.log("find all failed", Level.SEVERE, re); throw re; } }
private BufferedImage aplicaFiltroMatrizConvolucion( double[][] filter, double factor, double bias, BufferedImage img) { imgTmp = new BufferedImage(img.getWidth(), img.getHeight(), img.getType()); for (int x = 0; x < img.getWidth(); x++) { for (int y = 0; y < img.getHeight(); y++) { int r = 0, g = 0, b = 0; for (int filterX = 0; filterX < filter.length; filterX++) for (int filterY = 0; filterY < filter.length; filterY++) { int imageX = (x - filter.length / 2 + filterX + img.getWidth()) % img.getWidth(); int imageY = (y - filter.length / 2 + filterY + img.getHeight()) % img.getHeight(); Color c = new Color(img.getRGB(imageX, imageY)); r += c.getRed() * filter[filterX][filterY]; g += c.getGreen() * filter[filterX][filterY]; b += c.getBlue() * filter[filterX][filterY]; } imgTmp.setRGB( x, y, new Color( Math.min(Math.max((int) (factor * r + bias), 0), 255), Math.min(Math.max((int) (factor * g + bias), 0), 255), Math.min(Math.max((int) (factor * b + bias), 0), 255)) .getRGB()); } } return imgTmp; }
@Test public void max4float() { assertEquals(36.9f, Math.max(10.1f, 5.45f, -3.12f, 36.9f), 0.0); assertEquals(10.1f, Math.max(10.1f, 5.45f, -3.12f, 6.9f), 0.0); assertEquals(-3.12f, Math.max(-10.1f, -5.45f, -3.12f, -36.9f), 0.0); assertEquals(25.45f, Math.max(10.1f, 25.45f, -3.12f, 16.9f), 0.0); }
public void chartProgress(ChartProgressEvent chartprogressevent) { if (chartprogressevent.getType() != 2) return; if (chartPanel != null) { JFreeChart jfreechart = chartPanel.getChart(); if (jfreechart != null) { XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYDataset xydataset = xyplot.getDataset(); @SuppressWarnings("rawtypes") Comparable comparable = xydataset.getSeriesKey(0); double d = xyplot.getDomainCrosshairValue(); model.setValueAt(comparable, 0, 0); long l = (long) d; model.setValueAt(new Long(l), 0, 1); int i = series.getIndex(new Minute(new Date(l))); if (i >= 0) { TimeSeriesDataItem timeseriesdataitem = series.getDataItem(Math.min(199, Math.max(0, i))); TimeSeriesDataItem timeseriesdataitem1 = series.getDataItem(Math.max(0, i - 1)); TimeSeriesDataItem timeseriesdataitem2 = series.getDataItem(Math.min(199, i + 1)); long l1 = timeseriesdataitem.getPeriod().getMiddleMillisecond(); double d1 = timeseriesdataitem.getValue().doubleValue(); long l2 = timeseriesdataitem1.getPeriod().getMiddleMillisecond(); double d2 = timeseriesdataitem1.getValue().doubleValue(); long l3 = timeseriesdataitem2.getPeriod().getMiddleMillisecond(); double d3 = timeseriesdataitem2.getValue().doubleValue(); model.setValueAt(new Long(l1), 0, 1); model.setValueAt(new Double(d1), 0, 2); model.setValueAt(new Long(l2), 0, 3); model.setValueAt(new Double(d2), 0, 4); model.setValueAt(new Long(l3), 0, 5); model.setValueAt(new Double(d3), 0, 6); } } } }
private void setupContentDimensions(int count) { ArrayList<View> list = getItemsInReadingOrder(); int countX = mContent.getCountX(); int countY = mContent.getCountY(); boolean done = false; while (!done) { int oldCountX = countX; int oldCountY = countY; if (countX * countY < count) { // Current grid is too small, expand it if ((countX <= countY || countY == mMaxCountY) && countX < mMaxCountX) { countX++; } else if (countY < mMaxCountY) { countY++; } if (countY == 0) countY++; } else if ((countY - 1) * countX >= count && countY >= countX) { countY = Math.max(0, countY - 1); } else if ((countX - 1) * countY >= count) { countX = Math.max(0, countX - 1); } done = countX == oldCountX && countY == oldCountY; } mContent.setGridSize(countX, countY); arrangeChildren(list); }
public void fitToSize(int width, int height) { width = Math.max(width, 300); height = Math.max(height, 100); // this.setWidth(width + "px"); // this.setHeight(height + "px"); // setGridWidth(width - 10, height - 40); }