Android Open Source - android-weblogic-monitor Cluster Server State Pie Chart






From Project

Back to project page android-weblogic-monitor.

License

The source code is released under:

GNU General Public License

If you think the Android project android-weblogic-monitor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * *************************************************************************
 */* w w  w .  ja  va 2 s  .  c  o m*/
 * Copyright (c) 2013 - Jeffrey A. West Designs
 *
 * This code is provided for example purposes only.  Neither Oracle nor
 * Jeffrey A. West assume any responsibility or liability for the consequences
 *  of using this code. If you choose to use this code for any reason,
 * including but not limited to its use as an example you do so at your own
 * risk and without the support of Oracle.
 *
 * This code is provided under the following licenses:
 *  - GNU General Public License (GPL-2.0)
 *
 * **************************************************************************
 */

package com.jeffreyawest.weblogic.monitor.charting;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TextView;

import com.jeffreyawest.weblogic.entity.Cluster;
import com.jeffreyawest.weblogic.entity.ClusterServer;
import com.jeffreyawest.weblogic.entity.enums.ServerState;
import com.jeffreyawest.weblogic.monitor.R;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.renderer.SimpleSeriesRenderer;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by jeffreyawest on 8/10/13.
 */
public class ClusterServerStatePieChart extends DefaultPieChart
{

  private static final DecimalFormat percentFormat = new DecimalFormat("#");

  @Override
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
                           Bundle savedInstanceState)
  {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.chart_view_server_state, container, false);

    return view;
  }

  public void update(Cluster pCluster)
  {

    TextView healthHeader = (TextView) getActivity().findViewById(R.id.server_state_chart_header);
    healthHeader.setText(getActivity().getString(R.string.server_state));

    HashMap<ServerState, Integer> countMap = new HashMap<ServerState, Integer>(7);

    for (ClusterServer server : pCluster.getServers())
    {
      if (server.getState() == null || server.getState().toString().equals("null"))
      {
        continue;
      }
      Integer theCount = countMap.get(server.getState());

      if (theCount == null)
      {
        theCount = 0;
      }

      countMap.put(server.getState(), ++theCount);
    }

    List<Integer> valueList = new ArrayList<Integer>(countMap.size());
    List<Integer> colorList = new ArrayList<Integer>(countMap.size());
    List<String> nameList = new ArrayList<String>(countMap.size());

    for (Map.Entry<ServerState, Integer> entry : countMap.entrySet())
    {
      colorList.add(getActivity().getResources().getColor(entry.getKey().getColorID()));
      valueList.add(entry.getValue());
      nameList.add(entry.getKey().toString());
    }

    Integer[] VALUES = valueList.toArray(new Integer[valueList.size()]);
    Integer[] COLORS = colorList.toArray(new Integer[valueList.size()]);
    String[] NAME_LIST = nameList.toArray(new String[valueList.size()]);

    updateLegend(NAME_LIST, COLORS);

    mRenderer.setChartTitle(getActivity().getString(R.string.jvm_cpu));

    for (int i = 0; i < VALUES.length; i++)
    {
      mSeries.add(NAME_LIST[i] + " " + VALUES[i], VALUES[i]);
      SimpleSeriesRenderer renderer = new SimpleSeriesRenderer();
      renderer.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]);
      mRenderer.addSeriesRenderer(renderer);
    }

    GraphicalView pieChartView = ChartFactory.getPieChartView(getActivity(), mSeries, mRenderer);

    LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.server_state_chart_graphic);
    layout.addView(pieChartView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    pieChartView.repaint();
  }

  private void updateLegend(final String[] pNAME_list, final Integer[] pCOLORS)
  {
    TableLayout tl = (TableLayout) getActivity().findViewById(R.id.server_state_chart_legend);

    if (tl != null)
    {
      tl.removeAllViews();
      for (int x = 0; x < pNAME_list.length; x++)
      {
        tl.addView(getRow(getActivity(), pCOLORS[x], pNAME_list[x]));
      }
    }
  }
}




Java Source Code List

com.jeffreyawest.http.HTTPAdapterImpl.java
com.jeffreyawest.http.HTTPAdapter.java
com.jeffreyawest.weblogic.entity.ApplicationDatasource.java
com.jeffreyawest.weblogic.entity.ApplicationTargetState.java
com.jeffreyawest.weblogic.entity.Application.java
com.jeffreyawest.weblogic.entity.ClusterServer.java
com.jeffreyawest.weblogic.entity.Cluster.java
com.jeffreyawest.weblogic.entity.DatasourceInstance.java
com.jeffreyawest.weblogic.entity.Datasource.java
com.jeffreyawest.weblogic.entity.MaxThreadsConstraint.java
com.jeffreyawest.weblogic.entity.MinThreadsConstraint.java
com.jeffreyawest.weblogic.entity.RacInstance.java
com.jeffreyawest.weblogic.entity.RequestClass.java
com.jeffreyawest.weblogic.entity.Server.java
com.jeffreyawest.weblogic.entity.WebLogicEntity.java
com.jeffreyawest.weblogic.entity.WorkManager.java
com.jeffreyawest.weblogic.entity.enums.ApplicationHealth.java
com.jeffreyawest.weblogic.entity.enums.ApplicationState.java
com.jeffreyawest.weblogic.entity.enums.ApplicationType.java
com.jeffreyawest.weblogic.entity.enums.DatasourceInstanceState.java
com.jeffreyawest.weblogic.entity.enums.DatasourceType.java
com.jeffreyawest.weblogic.entity.enums.ServerHealth.java
com.jeffreyawest.weblogic.entity.enums.ServerState.java
com.jeffreyawest.weblogic.entity.enums.TargetState.java
com.jeffreyawest.weblogic.monitor.Constants.java
com.jeffreyawest.weblogic.monitor.WebLogicMonitor.java
com.jeffreyawest.weblogic.monitor.activity.EndpointEntryActivity.java
com.jeffreyawest.weblogic.monitor.activity.MainActivity.java
com.jeffreyawest.weblogic.monitor.activity.display.DisplayApplicationActivity.java
com.jeffreyawest.weblogic.monitor.activity.display.DisplayClusterActivity.java
com.jeffreyawest.weblogic.monitor.activity.display.DisplayDatasourceActivity.java
com.jeffreyawest.weblogic.monitor.activity.display.DisplayEntityActivity.java
com.jeffreyawest.weblogic.monitor.activity.display.DisplayServerActivity.java
com.jeffreyawest.weblogic.monitor.activity.display.fragment.ServerDetailsFragment.java
com.jeffreyawest.weblogic.monitor.activity.list.ListApplicationsActivity.java
com.jeffreyawest.weblogic.monitor.activity.list.ListClustersActivity.java
com.jeffreyawest.weblogic.monitor.activity.list.ListDatasourcesActivity.java
com.jeffreyawest.weblogic.monitor.activity.list.ListDomainEntitiesActivity.java
com.jeffreyawest.weblogic.monitor.activity.list.ListEntityActivity.java
com.jeffreyawest.weblogic.monitor.activity.list.ListServersActivity.java
com.jeffreyawest.weblogic.monitor.activity.list.adapter.ApplicationListAdapter.java
com.jeffreyawest.weblogic.monitor.activity.list.adapter.ClusterListAdapter.java
com.jeffreyawest.weblogic.monitor.activity.list.adapter.DatasourceListAdapter.java
com.jeffreyawest.weblogic.monitor.activity.list.adapter.DomainEntityListAdapter.java
com.jeffreyawest.weblogic.monitor.activity.list.adapter.ServerListAdapter.java
com.jeffreyawest.weblogic.monitor.charting.ApplicationTargetStatePieChart.java
com.jeffreyawest.weblogic.monitor.charting.Charting.java
com.jeffreyawest.weblogic.monitor.charting.ClusterServerHealthPieChart.java
com.jeffreyawest.weblogic.monitor.charting.ClusterServerStatePieChart.java
com.jeffreyawest.weblogic.monitor.charting.DatasourceInstancePieChart.java
com.jeffreyawest.weblogic.monitor.charting.DefaultPieChart.java
com.jeffreyawest.weblogic.monitor.charting.JVMCPUPieChart.java
com.jeffreyawest.weblogic.monitor.charting.JVMHeapPieChart.java
com.jeffreyawest.weblogic.monitor.task.RetrieveWebLogicEntityTask.java
com.jeffreyawest.weblogic.rest.WebLogicDemoRestAdapter.java
com.jeffreyawest.weblogic.rest.WebLogicHTTPRestAdapter.java
com.jeffreyawest.weblogic.rest.WebLogicRestAdapter.java