Here you can find the source of shortenLabel(String key)
Parameter | Description |
---|---|
key | the string to shorten. |
public static String shortenLabel(String key)
//package com.java2s; /*/*from w w w .j av a2s . c o m*/ * JPPF. * Copyright (C) 2005-2010 JPPF Team. * http://www.jppf.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Keywords to look for and replace in the legend items of the charts. */ private static final String[] KEYWORDS = new String[] { "Execution", "Maximum", "Minimum", "Average", "Cumulated" }; /** * The the replacements words for the keywords in the legend items. Used to shorten the legend labels. */ private static final String[] REPLACEMENTS = new String[] { "Exec", "Max", "Min", "Avg", "Cumul" }; /** * Replace pre-determined keywords in a string, with shorter ones. * @param key the string to shorten. * @return the string with its keywords replaced. */ public static String shortenLabel(String key) { for (int i = 0; i < KEYWORDS.length; i++) { if (key.indexOf(KEYWORDS[i]) >= 0) key = key.replace(KEYWORDS[i], REPLACEMENTS[i]); } return key; } }